REST Attachment API with Base64 String

robinson_gregor
Kilo Contributor

Hi,

I am trying to use the REST Attachment API (/api/now/attachment/file) to add an attachment that is formatted as a Base64 string. I have put the string in the "Raw" section in the body, but it is just creating the file with the Base64 string in it.

Is there any way to make this work using a Base64 string?

Thanks!

1 ACCEPTED SOLUTION

bryanbarnard
ServiceNow Employee
ServiceNow Employee
3 REPLIES 3

bryanbarnard
ServiceNow Employee
ServiceNow Employee

No, the REST Attachment API accepts attachments in binary or multipart format.



Attachment API - POST /now/attachment/upload



Binary: Attachment API - POST /now/attachment/file


Multipart : Attachment API - POST /now/attachment/upload



There is a SOAP endpoint that accepts Base 64.


Sending an attachment to ServiceNow via Web Services - ServiceNow Guru


Thank you Bryan!


Keith2
Kilo Explorer

Hi,

I was trying to do the same thing here. I used the Attachment API to post a binary file in the data of the POST request with content-type: "text/plain", and charset: 'utf-8'. I saved the file name with a .txt extension. I wanted to get the text file as the attachment but the content was in binary. Am I missing any conversion step/ having the wrong content-type set or is it not how the POST ATTACHMENT API's supposed to work?