function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rajasekhar MekalaRajasekhar Mekala 

add images to rich text area fields in knowledge articles via rest api

Hi, I am a newbie to salesforce knowledge and I have been trying to publish articles to salesforce lightning knowledge via REST API. I am having trouble figuring out the way to add an image in rich text field areas in articles via APIs for a while now. From the UI,  when I click the image option in the UI, it creates a link like this

<img alt="" src="https://c.ap17.content.force.com/servlet/rtaImage?eid=ka02x0000005Qny&feoid=00N2x000000xPaN&refid=0EM2x000000PW60" />

I could not figure out how to upload articles to this servlet and get back a similar URL as a response, so that I can use these links in rich text areas. Can someone point me in the right direction?

Thanks,
Rajasekhar
VinayVinay (Salesforce Developers) 
Hi Rajasekhar,

That domain (c.ap17.content.force.com) is checking the session and hence the image is private.  Make the site public.

Review below link for same.
https://salesforce.stackexchange.com/questions/36503/how-to-set-public-inline-images-in-knowledge-base-article

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
Rajasekhar MekalaRajasekhar Mekala
Hi Vinay, 

Thanks for the quick reply. Perhaps there is a little confusion with my question. My question is, How can I upload an image in knowledge article fields(like rich text areas) using REST API?
VinayVinay (Salesforce Developers) 
Review below links which has working examples and gives more information.

https://salesforcetrail.blogspot.com/p/upload-file-using-multipartform-data.html
https://www.topcoder.com/reblog-post-multipartform-data-with-httprequest-by-enreeco/
https://salesforce-season.blogspot.com/2017/05/http-request-with-multipartform-data.html
https://blog.enree.co/2013/01/salesforce-apex-post-mutipartform-data.html

Hope above information was helpful.

Thanks,
Vinay Kumar
Shajadi shaikShajadi shaik
HI 

Try this

public class ImageUploadOnRichTextArea {
    
     Public void ImageUpload(){
    Product_Manual_kav__c knowledge = [Select Item_Picture__c from Product_Manual_kav__c where Id = 'ka152000000DEqiAAG'  ];
        knowledge.Item_Picture__c = '<img alt="Added image on knowledge" src="https://images-na.ssl-images-amazon.com/images/I/719MLRo58OL._SL1500_.jpg" width="150" height="100"></img>';
        Update knowledge;
         System.debug(knowledge.Id);
         
       
     }
}