Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to load Attachments to table using REST API for the custom file attachment fields.

ah16
Mega Expert

Hi,

I have custom multiple fields of type file attachment. How can I load attachments thru REST API to the custom file attachment fields?

 

Where to find how this table name created for this custom fields  "zz_yydmn_demand" ?find_real_file.png Thanks,

Ashraf

1 ACCEPTED SOLUTION

Hi,

what I was able to achieve is below:

1) Use Attachment API to create file -> it would create an attachment record in sys_attachment table

POST: Upload an attachment from a binary request

Gave table name as ZZ_YYtable_name; in your case it would be ZZ_YYdmn_demand

Gave the table_sys_id -> record sys_id

file name -> you want

Request body -> attachment data

2) now you will have to populate the attachment sys_id from step 1 in the field which is of type File Attachment on that record; once you update that field with that sys_id it should start showing

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Hi,

what I was able to achieve is below:

1) Use Attachment API to create file -> it would create an attachment record in sys_attachment table

POST: Upload an attachment from a binary request

Gave table name as ZZ_YYtable_name; in your case it would be ZZ_YYdmn_demand

Gave the table_sys_id -> record sys_id

file name -> you want

Request body -> attachment data

2) now you will have to populate the attachment sys_id from step 1 in the field which is of type File Attachment on that record; once you update that field with that sys_id it should start showing

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Got it. Thanks for all your help.

How do you create an attachment record at first if it's asking for a sys_id in the request? Which operation did you use? thank you