Images are not passing in Knowledge article using rest API method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2024 11:06 PM
Images are not passing in Knowledge article body using rest API method from one instance to another. In the target instance it is just showing image icon not image.
Please suggest method to pass the image in article body.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2024 11:34 PM
Hi @amit71 ,
This thread should help you :https://www.servicenow.com/community/developer-forum/not-able-to-send-images-through-servicenow-api-...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2024 11:46 PM
Hello @amit71 ,
It might be because of encoding issue.
In the source instance, retrieve the image data from KB using binary using getDisplayImage() or getBinaryStream() and then encode the retireve ninary data into Base64 format using -
GlideStringUtil.base64Encode(imageData)
In the target instance, within script that processes API response decode Base64 data back to binary using
GlideStringUtil.base64Encode(encodedImage). create a new attachment record in the target instance with the decoded binary dta. Update article body to reference newly created attachment using appropriate format like !{sys_id of attachment}
if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
CB