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.

Accepting Inbound Attachements via REST API

kdurg
Kilo Guru

Hey all,
I am looking to create a Scripted REST API that will accept inbound attachments. I have designed an endpoint that accepts payload data and creates a support case. I would also like to allow attachments via the same endpoint, is this possible? I am looking at the attachment API but I don't see a way to target the inbound attachment file. Thanks in advance for the help!

8 REPLIES 8

Hi,

To clarify the process;

An attachment is not posted to the REST API end point that was used to insert/update your record, but is posted directly to the target record (case) with one of the dedicated attachment API’s,

So you need to Post your new case via the scripted REST API endpoint,
then using the data returned in the response from the task post IE sys_id and table (if table not known) you POST the attachment directly to the target record.

This helps a bit, thanks. 

To make sure I understand, if my REST API first creates the case, then pulls the table and sys_id of the case, I could make a secondary call to the attachment API to add the attachment that way? How would I be able to "copy" the inbound attachment file to be sent to the Attachment API? Sorry if this is confusing (probably because I am a little confused still, ha!)

I believe it would help if you clarified the nature of the system doing the REST API calls that are to create a Case and attachments for it.

Hi, your solution will depend on how your source platform is posting the new record and attachment. Posting to the target table will depend on you returning the target details to your source platform and this would need to be thought through carefully.
One other option that may simplify your process could be to post the attachment to your 'new' record that's created in your API endpoint table, and then as part of the subsequent transform update the attachments record to point at the target table and record.