- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2025 04:31 AM
Hi all,
I want to write a scripted api to upload the photo to user table. Here is my code but failed. Please help to correct the code.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2025 07:53 AM
try this link where I shared solution to attach file via scripted rest api then enhance it based on your requirement. once the image is copied to record, simply query sys_attachment with this user sysId and update the table name as 'ZZ_YYsys_user'
Scripted Rest API to update incident with attachment
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2025 04:38 AM
Hi @JackieZhang
this post might help you
https://medium.com/@AServiceNowDev/updating-user-photos-via-rest-in-servicenow-f5da50c00627
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2025 04:51 AM
what error it gave?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2025 06:02 AM
Here is my lastest code. the attahment has been added but the photo was broken and can't be opened
By the way,I used this online tools to transform the image to base64 string. https://www.jyshare.com/front-end/59/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2025 06:55 AM
does the request body contain base64encoded data?
if yes then you are in global scope or scoped app? where did you write the code?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
