What's raw data in REST Attachment API

Gaurav Bajaj
Kilo Sage

Hi

I am in middle of posting an attachment( lets says an image of jpeg format) with Rest Attachment API. I am confused about the raw data to be used in the request,

I have been trying it with Rest API Explorer and unable to find what is supposed to be added in raw data.

I don't want to upload a file directly through Binary data option as I am getting the data in base64 format from a 3rd party.

PS: I also don't want to use ECC-queue function to add an attachment.

find_real_file.png

Any light on it is highly appreciated.

Thanks

Gaurav

1 ACCEPTED SOLUTION

Hi Andrew



I got it working as I was calling the table API and not attachment API here.


Took reference from the below link.



https://community.servicenow.com/thread/266337#1153136




Thanks for your time.


View solution in original post

9 REPLIES 9

dravvyramlochun
ServiceNow Employee
ServiceNow Employee

Hello gauravbajaj2007



In the Request Body section, define the body content of the request. This section appears for methods that insert or update data, such as PUT. The Request Formatthat you select in the Request Headers section determines the format you must use in the request body, such as JSON or XML.


You can build the request body by selecting fields, by manually writing the request body, or by uploading a binary file.


Use the Builder tab to build the request body using instance fields. Click Add a field, then select a field and specify a value. Available fields depend on the table you are adding data to.


Use the Raw tab to manually enter a request body.


Use the Binary tab to upload a binary file. This tab appears only for APIs that support binary file data, such as the Attachment API.


Reference:


REST API explorer elements


Thanks for your reply Dravvy, but i have already gone through these solution and my concern is to add raw data for an image which can be base64 encoded.


Maybe the post in this article can help you:


How to fetch encoded attachment for an incident via REST API


andrew_venables
ServiceNow Employee
ServiceNow Employee

Hi Gaurav,



There are a couple of examples on the docs site on how to post a binary file to the Attachment API:



Attachment API - POST /now/attachment/file



These cover curl and python examples.



What technology is your source system based on?



Andy