Quick win 12. (How to) retrieve image from Richtext field with REST API in Salesforce
Aug 10, 2022
The Objective of this article is to share how can a developer extract the image from the Richtext field on any object using REST API
How to do it
There are 4steps to it
- Create an object / use any existing one e.g say Knowledge standard object
- Create a new RichText type field named Details
- Get ready with your Postman and call the GET sObject request
- endpoint :/services/data/v55.0/sobjects/knowledge__kav/ka15e0000011oBYAAY (where “ka15e0000011oBYAAY” is my record Id)
- response: FAQ_Answer__c”: “<img alt=\”Screenshot 2022–08–09 at 14.15.51.png\” src=\”https://mohitchhab-20210713-demo--c.documentforce.com/servlet/rtaImage?eid=ka15e0000011oBY&feoid=00N5e00000TbmXY&refid=0EM5e000001q21x\"></img>"
4. copy the “ref Id” from the response from the respective richtext field shown in the response and prepare to make another Get call to the following resource :
- GET: /services/data/v55.0/sobjects/knowledge__kav/ka15e0000011oBYAAY/richTextImageFields/FAQ_Answer__c/0EM5e000001q21x
You will see the image in response!
That’s all for today., Cheers Mohit