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
sujithkumar j 9sujithkumar j 9 

Access the Library List Data Through The Rest Public api

HI All,

            We are having pdf files on the Library Object . We are using HTML Native app for accessing the rest apis from the salesforce.We need to get the list of Libary ids from the salesforce.For that we developed the below Rest api.

@RestResource(urlMapping='/LibraryList/*')
global class LibraryListController 
{
    @HttpGet    
    //global static List<ContentWorkspaceDoc> retrieve()
    global static List<ContentWorkspace> retrieve()
    {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        res.addHeader('Access-Control-Allow-Origin', '*');
        res.addHeader('Content-Type', 'application/json');
         res.addHeader('Accept', 'application/json');
        res.addHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE');
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); 
        //List <ContentWorkspace> Lib= [SELECT ParentId,ContentDocumentId,ContentWorkspaceId,Id FROM ContentWorkspaceDoc]; 
        List <ContentWorkspace> Lib= [SELECT Id,Name FROM ContentWorkspace];               
        return Lib;
     }
}

We are sending our apis through our site.Example url  https://ap2.salesforce.com/SampleSite/services/apexrest/LibraryList..
If we are trying to acces this from workbench we are getting the data. But if we run this url publicly we are not getting responce.The reamining all apis we are able to get data.

Can any one please suggest How to get data from the Library.Please help us with your suggestions