Not able to send images through servicenow API apart from text

Hari Servicenow
Kilo Explorer

I have a knowledge base table in Servicenow where it contains Images, Another team needs data from that table, So I have sent API where they can see text but not images. Could someone help me on this?

2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, most API's pass data in text (ascii) format, with any image or file requiring encoding\decoding so that it can be passed as text; So if you want user to retrieve embedded images\files via API then you will need an API solution that encodes and passes the files\images to a target platform\viewer for decoding.

https://developer.servicenow.com/dev.do#!/reference/api/sandiego/server/no-namespace/c_GlideSystemScopedAPI#r_SGSYS-base64Encode_S?navFilter=base64

 

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Hari,

Images are saved in a different table. Either "db_image" or "sys_attachment" table.

As such, it is necesary to use a different API to retrieve them.

If the image is in sys_attachment table, use the Attachment API's "Retrieve attachment content (GET)" api.

URL is as follows. This will return the file in binary format.

https://<instance name>.service-now.com/api/now/attachment/<sys_id in sys_attachment table>/file

Another way is to create a text field in the table and have an after business rule to save the image as base64 encoded format in that field. User would have to decode the base64 encoded image after retrieving the data.

Another option is to convert the knowledge page to pdf and have a Scripted API to download the pdf file.