How to get the attachment from a specific ticket by api ?

fandy
Kilo Contributor

I tried "api/now/v1/attachment/<sysid>" but got errors as   the statement below.

{"error":{"detail":"Record doesn't exist or ACL restricts the record retrieval","message":"No Record found"},"status":"failure"}

I am sure that the <sys_id> is right and I can queried the ticket by the <sys_id>.

Does someone know how to fix it or the right way ?  

Regards and thanks,

Fandy

5 REPLIES 5

Chuck Tomasi
Tera Patron

Have you tested this with the REST API Explorer?



I think for the get, you specify the sys_id in the sysparm_query section, not on the URL.



Docs: REST API Explorer


Docs: https://docs.servicenow.com/bundle/jakarta-application-development/page/integrate/inbound-rest...


We already tested "https://XXXX.service-now.com/api/now/attachment?sysparm_limit=10&sysparm_query=ile_name=backup-4.xls "   but it still shows many records not related to this attachment.    


The sysparm_query should include the table name and table sys_id of the record you are after. Example



table_name=incident^table_sys_id=xxxxxxxxxx



Here's an example I did in REST API explorer.


find_real_file.png


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Fandy,



Here you go.


https://YOURINSTANCENAME.service-now.com/api/now/v1/attachment?sysparm_query=table_name=incident%5Et...



Here replace d71b3b41c0a8016700a8ef040791e72a with the record sys_id and Incident with the exact table name.