Send attachment using REST api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2017 03:58 AM
Hello All,
Can you please help me understand how the requirement can be delivered..
I have seen many articles on posting an attachment to a specific incident/ change tickets. But take an example I want send a excel file to the below the api
https://<Servicenowurl>/api/now/attachment/file
then Service now imports it to the respective table.
Ex: Take a csv that has around 100 contacts and I post to a REST API link. Finally the excel has to be opened and loaded into the users table or a temporary table of service now.
If any body has done this please reply back on the steps and code.
Thanks.
Regards
Param
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2017 12:47 AM
Hello Param, I checked and you won't be able to use REST Attachment API for loading data into import set table as it is suppose to attach a file to a record as mentioned by Josh. Not really sure about your exact requirement but if it has to be done manually then I would say make it simple and load data manually using import sets. On the other hand if you want this import to be scheduled then please create a data source with an appropriate file retrieval method and a file path as well from system can retrieve the data and scheduled it accordingly. Doing so system will pick your attachment from the given file path accordingly and load the data. But, again you have to make sure that you have a respective import set table exist in the system for the same.
Please check Data sources and Schedule a data import links for more details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 10:39 PM
Thanks, I am able to send file via REST API Explorer. But unable to send attachment via Postman to Service now, can you provide the steps for Postman to service now.
I tried like below
Method: Post
form-data :
file: <choose a file from upload button>
Header:
Content-type: multipart/form-data
Note: I used basic authentication
I got error as response:
{
"error": {
"detail": null,
"message": "Failed to create the attachment. File part might be missing in the request."
},
"status": "failure"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2017 12:29 AM
Hello Prantish,
I am also getting the same error. Did you got any solution ?
Any help would be appreciated.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2017 02:06 PM
Hello,
The REST Attachment API is probably not what you want for the use case you describe. It can be used to attach a file to a record in ServiceNow, but it does not facilitate loading/transforming attached data.
Instead, take a look at this page on the docs site: Post CSV or Excel files directly to an import set. This allows you to upload an attachment to a special endpoint that will then load the attached data into an Import Set table and Transform it.
Before posting the file, you must first set up an Import Set and Transform map. Here's a post that explains the basics: Getting Started with Import Sets.
In summary, you will need to:
- Create an Import Set / Transform Map
- Use the special sys_import.do endpoint with the parameters described above to upload the file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2017 01:12 PM
I was able to send file using postman. Please find screenshot below:
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
https://stackoverflow.com/questions/39280438/fetch-missing-boundary-in-multipart-form-data-post