Any examples of a multipart/form-data posting attachment content using REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 07:17 AM
Been struggling with this for ages, able to send the meta data using the POST <instance>/api/now/attachment/file but when using the POST <instance>/api/now/attachment/upload with the content of the file it always returns -
'{"error":{"message":"Failed to create the attachment. File part might be missing in the request.","detail":null},"status":"failure"}'
Tried an array of methods with the multipart in php and none of them seem to return anything other then this
Please help
TIA
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 07:19 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2017 02:56 AM
I am getting the same error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2017 11:51 AM
I was able to post it using postman. check screenshots below:
Note: Don't supply content type in headers when using postman.
Note from stackoverflow post:
Beware, when testing your webservice using chrome postman, you need to check the form data option(radio button) and File menu from the dropdown box to send attachment. Explicit provision of content-type as multipart/form-data throws an error. Because boundary is missing as it overrides the curl request of post man to server with content-type by appending the boundary which works fine.
Link: html - What is the boundary in multipart/form-data? - Stack Overflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2018 02:55 AM
Hi Owainr,
Its been confirmed by ServiceNow that they do not support content-type as "multipart/form-data" .The only solution is either use Mid server or create own proxy server where you can send as Binary Stream .
There are others content-type as "Application/Json" which you can use.
Just to keep in mid that ServiceNow sends Text data out of ServiceNow.
reference:
https://community.servicenow.com/community?id=community_question&sys_id=a8df36addb58dbc01dcaf3231f9619fb
https://community.servicenow.com/community?id=community_question&sys_id=c78487a9dbd8dbc01dcaf3231f96191d
or You can take help from Here
https://docs.servicenow.com/integrate/inbound_rest/reference/r_SamplePOSTMultipart.html
Please hit like if this helped you.
regards
Sandeep