The CreatorCon Call for Content is officially open! Get started here.

hammad ul aziz2
Mega Guru

we are about to post base64 Encoded string to image type field

step-1 : lets create a image type field on incident form with the following configurations

find_real_file.png

step-2 : Select any image that you want to post to the above field, and navigate HERE to convert image to base64 encoded string. keep the browser tab open we will need the above base64 encoded string later on.

find_real_file.png

step-3 : here is the endpoint which we will use to post base64 encoded string directly to the image type field, https://yourInstanceName.service-now.com/api/now/table/ecc_queue

we will use post man for chrome to post base64 encoded string

endpoint details

METHOD : POST

BODY : application/json

BODYTemplate :

{
	"agent":"AttachmentCreator",
	"topic":"AttachmentCreator",
	"name":"u_profile_photo:image/jpg",
	"source":"incident:7b3e4a7cf0212300964feeefe80ff04b",
	"payload":"/9j/4AAQSkZJRgABAQEBLAEsAA"
}

keep the agent and topic as AttachmentCreator

name: you should provide field name here to which you want to post an image. here our field name is u_profile_photo and after colon provide image type.

source: source will contain a colon separated table name and sys_id of a record to which you want to post an image.

payload: this is our base64 encoded string that we need to pass here. 

step-4: lets start building the above request using post man.

find_real_file.png

keep the Authentication as Basic Auth and provide admin username and password,

find_real_file.png

now hit the send button and you will get the response something like this

find_real_file.png

Here is the end result of how will image look like on the form.

find_real_file.png

mark this as helpful if this helped, if you have any queries please do post.

thanks & Regards

Hammad Ul Aziz (Sr. Developer)

Comments
hammad ul aziz2
Mega Guru

I Hope this is helpful.

hammad ul aziz2
Mega Guru

s

Rasmita
Tera Contributor

I tried the above approach on catalog item record on icon field, the image is getting attached correctly on the record and shown correctly however the the icon field has broken image. Any solution for the same?

hammad ul aziz2
Mega Guru

@Rasmita can show me what it looks like? Maybe try reducing the image resolution/size!

Sachin Gavhane
Giga Guru

i tried this using postman and it is working fine , but how to do this in service now itself, can u pls help

Luiz Schmidt
Tera Explorer

Hi Hammad, 
What changes would be necessary to add this as an attachment to the record?
Thank you!

Version history
Last update:
‎01-19-2021 11:04 PM
Updated by: