You need to sign in to do that
Don't have an account?
sujithkumar 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
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