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
Tirumala Kuppani 10Tirumala Kuppani 10 

How to get the Knowledgebase documents through REST API

Hello

Req: get the Knowledgebase documents through REST API.

I was strusk at get the Knowledgebase documents through REST API.

Please find below Webservice class for get the Knowledgebase documents.

@RestResource(urlMapping='/KB/*')
global with sharing class KBDetails {
@HttpGet     
global static List<RMA_Policy__kav> kbDetails() {     
String pblist = RestContext.request.params.get('pblist');   
 // system.debug('localPublishStatus : '+localPublishStatus );            
List<RMA_Policy__kav> kbDetailsList = [select id, ArticleNumber, ArticleType, Title, Summary,Question__c,Answer__c, knowledgeArticleId                                               from RMA_Policy__kav where PublishStatus=:pblist];           
system.debug('kbDetailsList : '+kbDetailsList );     
return kbDetailsList;    
 }    
 }

Kindly let us know how to get the KB documents hrough REST API
Any help will be appreciated.

Regards
Tirumala

 
Raj VakatiRaj Vakati
Hi Tirumala, 
Your code seems ok.  Go to Workbench and test it with the URL 
/services/apexrest/KB/<Pass the published status >
Example : - 
/services/apexrest/KB/draft