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

Kristy Merriam
Administrator
Administrator

Can your external API send the file via base64 string in the JSON? You could use the writeBase64 method to create an attachment via a Script REST API:

https://developer.servicenow.com/dev.do#!/reference/api/sandiego/server/no-namespace/c_GlideSysAttac...

This seems close to what I am trying to accomplish. Any idea how I can get the attachment? For example, do I need to assign the attachment like I would when trying to get the JSON payload (ex: response.body.data)? I am most confused how to target the inbound file. Thanks!

Kieran Anson
Kilo Patron

The two OOB attachment api's should be sufficient, for both you specify the sys_id and table name. Is your custom SRAPI returning these values to which the sender could use to make a secondary call to send the attachments.

I am looking for an external system to send me a payload and attachment file, for which I will then save the attachment and create a case with with payload data. I would rather not allow outside sources to be able to directly query the attachments table, but add a safe guard of the API endpoint in between. Do you know if there is an OOB feature that covers that? Thanks!