Not able to attach files to incident through REST API

nehasr1288
Tera Expert

When I try to raise an incident using rest api ,I

tried to attach a file but the incident is raised but file is not attached

Capture.png

1 ACCEPTED SOLUTION

Hi Neha,



I was able to do this successfully.



You should change sys_id to table_sys_id and also check the post query string checkbox. Please try and let me know



find_real_file.png




Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

11 REPLIES 11

larstange
Mega Sage

Hi



You need to first create the incident and save the returned sys_id.



Then you have to use the attachment API to add the attachment after the incident record has been created



Video: How to Make REST Attachment API Requests


Hi,



It is working from the REST API explorer we have in service now but when using an external tool SOAP UI to create such a rest request it is not working.


Capture.png


larstange
Mega Sage

In your screenshot you are using the Table API - this cannot be used to upload files.



The url to the attachment api would look like this


https://instance.service-now.com/api/now/attachment/file?table_name=incident&table_sys_id=d71f7935c0...



https://developer.servicenow.com/app.do#!/rest_api_doc?v=helsinki&id=r_AttachmentAPI-POST


Yes but when I use the same URL to insert attachment (using attachment API) I get an error.


find_real_file.png


Secondly I have to also enter the sys_id.It should happen with incident number