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
10-09-2018 12:56 PM
I was facing the same issue, got HI team on this and servicenow DOES accepts form-data format, although it wont accept files to be attached (unless you are on LONDON and the Integration Hub plugin needs to be purchased ($$$$), and it will be available ONLY on "Flow Designer" where you could use the "file" form-data as postman does, but instead of using "upload file" it will use the sevicenow sys_id's under sys_attachment_list.do).
Try this:
var r = new sn_ws.RESTMessageV2('<12312312312321>', 'POST');
var var1 = "test1";
var var2 = "test2";
var var3 = "test3";
r.setStringParameterNoEscape('form1', var1);
r.setStringParameterNoEscape('form2', var2);
r.setStringParameterNoEscape('form3', var3);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
Please mark as this as helpful if it was.
Regards