The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Send attachment using REST api

Paramahanns
Tera Expert

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

14 REPLIES 14

lks
ServiceNow Employee
ServiceNow Employee

Hello Param,


Please check below the videos from Attachment AP, I hope it will help you.


Thanks for your replies. I had a look before I posted the question. But this is related to the attachment that can be posted to a incident ticket or change ticket as I earlier mentioned. The requirement that I am asking is importing an attachment into the user table as an example.



Regards


Param


lks
ServiceNow Employee
ServiceNow Employee

Steps are same for adding an attachment to sys_user also. I tried below steps on OOB demo instance and able to attach an attchment successfully:



1. Login to an OOB Geneva instance.


2. System Web Services > REST API Explorer


3. Namespace: now, API Name: Attachment API, API Version: latest


4. Upload an attachment from a multipart form (POST)


5. Request headers:


      a) Request format: multipart/form-data


      b) Response format: application/json


      c) Authorization: Send as me


      d) Content-Type: application/json (added new)


6. Request body:


      a) table_name: sys_user


      b) table_sys_id: 62826bf03710200044e0bfc8bcbe5df1 (sys_id of abel.tuter OOB user)


7. Upload a file: select as per your choice and click Send button.



Result: Attachment is added to sys_user "abel.tuter" record.



Let me know if you need further assistance!


Thanks for your replies. I will try to explain better. It is not adding the attachment to the user record. Ex



I have a excel sheet with 100 records



1. Param


2. Lalit


3. Kumar


4. Hanns


Like this I have 100 records and using the rest file upload I just need to upload all the records from the excel sheet as a record in the sys_user table.



Regards


Param