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
surendrababu ksurendrababu k 

Need Clarification on REST API's.

Hi Folks..
I'm new to the API's and Integration, I need clarification on these below points....

1. We have some documents in salesforce libraries, can we fetch those documents via REST API without logging in?

2. As per salesforce documentation we have to login via REST API and generate oAuth token to fetch any data from salesforce, is there any way to bypass that login and fetch content from libraries directly?

3. Can a single user login to multiple devices via REST API? Will the oAuth token be valid on all devices if I login using the same credentials at the same time to fetch data via REST API?

4. Can we fetch the Related Content related list data from Custom object via SOQL/APEX queries?

Thanks in advance..
Surendra Babu

 
pconpcon
  1. No, you will need to authenticate to access all REST APIs.  You could do something like creating a Visualforce page that returns JSON and make that a site, but I don't know if that would go against Salesforce's ToS
  2. You can log in via SOAP and pass the SessionId (via the Authentication: Bearer header)
  3. The oAuth token is valid across multiple devices.  That's just how oAuth works.
  4. Yes, you would do this just like you would any normal SOQL query.
surendrababu ksurendrababu k
Hi Pcon, Thanks for quick reply with valuable information.. Reg point no 4: I am trying to fetch the related content related list data for an custom object by using below query,But it doesn't return any response. SELECT (SELECT ContentDocumentid,Title,Id FROM AttachedContentDocuments),Id,Name FROM Custom_Object__c even ii tried with Standard object as well but it doesn't return anything. Appreciate your help on this!! Regards Surendra
pconpcon
That query should work.  If you query the AttachedContentDocument with a ParentId from the Custom_Object__c do you get results back?
surendrababu ksurendrababu k
Hi Pcon,

I tried to fetch the related content data from Products standard object by using below query. Query excecuting successfully,but it doesn't return any thing.

SELECT (SELECT ContentDocumentid, Title, Id FROM AttachedContentDocuments), Id, Name FROM Product2

Please let me know is there any modifications needed on above query.
pconpcon
Actually, it looks like you can't query the AttachedContentDocument object [1].
 
Use this object to list all ContentDocument objects attached to an object via a feed post.
 
To retrieve ContentDocument objects, issue a describe call on an object, which returns a query result for each activity since the record was created. You can’t directly query this object.

[1] https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_attachedcontentdocument.htm
surendrababu ksurendrababu k
Thanks you notes on this Pcon. Yes,I tried on different ways even though I'm unable to retrieve the data from this object via SOQL Queries. Regards Surendra