rest api for fetching cat_item images

mksharma
Kilo Contributor

I am trying to get images of the item using the rest api /api/sn_sc/servicecatalog/items?sysparm_text=laptop

the image field is missing in the response.

when I try the rest api api/sn_sc/servicecatalog/items/8b6abec14f86c68085b73485f110c7fa   it does not give the field.

even I tried on api/now/table/sc_cat_item/8b6abec14f86c68085b73485f110c7fa

the field is present here but comes blank..

but when I try on the UI I see an image...

what api will help fetch me the image?

5 REPLIES 5

Geoffrey2
ServiceNow Employee
ServiceNow Employee

The picture is not stored on the sc_cat_item table.


In the screenshot you can see an image in the Picture field of this Catalog Item.


But if you look at the XML of the record there is no value in that field.


Images are stored on the sys_attachment table.


For Image type fields, the table name is prefixed with 'ZZ_YY' (don't ask me why). Eg, ZZ_YYsc_cat_item. It's how they are differentiated from normal attachments.


You can get the image from here by searching for the sys_id of the Catalog Item in the table_sys_id field.


Screen Shot 2016-09-13 at 9.05.23 PM.png


Screen Shot 2016-09-13 at 9.05.52 PM.png


Screen Shot 2016-09-13 at 9.07.25 PM.png


Thanks Geoffrey. I am using Helsinki version. when I send the request api/now/table/sys_attachment/8b6abec14f86c68085b73485f110c7fa


or


api/now/table/ZZ_YYsc_cat_item/8b6abec14f86c68085b73485f110c7fa


it gives invalid table ZZ_YYsc_cat_item.



I am not able to figure out from the table explorer which alternate table contains the images.



not sure if I am missing something. can you suggest?


Geoffrey2
ServiceNow Employee
ServiceNow Employee

There is a different API for attachments.   Take a look at the REST API Explorer, and select Attachment API from the API Name list.Capture.PNG


if I give the item sys_id in this field I get a 404 error.   whereas the image is displayed on the item record.


If I give the attachment/image sys_id ( i tried for the icon one) it gives me the 200 response.



the question is how to get the image sys_id from the sc_cat_item... there is no table ZZ_YYsc_cat_item nor sys_attachment table in the helsinki version.