Using Attachment API - POST /now/attachment/file

preethi_premnat
Kilo Explorer

Hi All,

I have been trying to consume the Attachment API available in the Geneva Release to be able to attach certain files (images,xls etc) to existing records on a table.Using the REST API Explorer, I was able to upload a file by providing the path in the 'Binary' tab.However, I am unaware as to how we could do the same through the Request Body while making the REST call.

I tried using parameter 'uploadFile' to provide the file path, just as we see in the snippet but instead it takes it as a text and creates an attachment.

I also tried passing the Base64 encoded string for an image but instead it creates a corrupted image attachment.

Kindly advise what I am missing here.

Thanks and Regards,

Preethi

Message was edited by: Preethi Premnath

3 REPLIES 3

prithvirajchaud
Mega Expert

I am not sure about it but maybe this thread could help you


Attach a file using rest api


Hi Prithviraj,



Thanks for your response.However, I need upload files from a location outside ServiceNow and then attach them to existing records on the instance.As I understand , to use the method setRequestBodyFromAttachment(), we require the attachment sys id which in my case wont work.



Regards,


Preethi