Upload User Photo Using REST API?

Austin N
Tera Contributor

Is it possible to upload a user photo/avatar icon using REST API?  I have tried uploading the photo using the Attachment API, setting the table_name to ZZ_YYsys_user and the table_sys_id to the user's sys_id value as explained in this article, but this results in a 'broken' image:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0693478

 

I have also tried updating the ecc_queue table as explained in this article:

http://www.john-james-andersen.com/blog/service-now/post-picture-image-field-rest.html

 

This appears to upload the photo, and the image shows in the photo field on the user's record, but the photo does not show in the avatar icon in the top right of the navigation bar

6 REPLIES 6

johnfeist
Mega Sage
Mega Sage

Hi Austin,

There are two photo fields in the user record (sys_user), Avatar and Photo.  Have you tried adding the photo to both fields?

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Hi John,

I did add the photo to the Avatar field as well - the photo displays correctly when viewing the user record, but still does not show in the avatar/icon in the top right of the navigation

Thanks,

Austin

Hi Austin,

I just did the quick test and uploaded a picture to a user's Photo field and it showed in the avatar field (top right).  The next dumb question for you.  What is the file type and size of the picture that you are trying to use?  It may be possible that a too large image cannot be effectively scaled down to fit the avatar space.  Of course, there's nothing in the documentation on this beyond that a photo can be attached.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Hi John,

You used REST API to upload the picture?  something like:

curl "https://instance.servicenow.com/api/now/table/sys_user/{user_sys_id}" \
--request PUT \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{'photo':'[image as base64 string]'}" \

I am trying to use a .PNG as the photo - everything works fine when I upload the file manually into the user's photo field, but when I upload it with the REST API, the image appears broken

Thanks

- Austin