+ Start a Discussion
KJ1122KJ1122 

fetch files through rest API

Hi All,
I am new to Salesforce and looking at the documentation. My basic use case is that i have Salesforce out of the box with no customization. I basically have some files uploaded as attachments and i basicaly want my platform (outside of saleforce) to retreive the files.
Is there an API for the same which we can just implement to fetch the files? (FYI i am using lightning platform)
Best Answer chosen by KJ1122
AnudeepAnudeep (Salesforce Developers) 
You can use the REST API to retrieve the attachments. Use workbench or postman and do a GET to the following URL
https://your_instance/services/data/v43.0/query?q=select id, LinkedEntityId,ContentDocumentId from ContentDocumentLink where LinkedEntityId = '003xxxxxxxxxx'

ContentDocumentId field in ContentDocumentLink stores the file references associated with the parent entity. ContentDocument stores the file relationships & references, while ContentVersion object stores the versions and the file-content references

Anudeep

All Answers

AbhishekAbhishek (Salesforce Developers) 
Hi,

You might find the Working with Salesforce Files

(https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/features_files.htm) documentation is useful to get the REST resource that lists the related files.


A direct SOQL query is also possible against it (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_note.htm)

 and Attachment

(https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_attachment.htm)


For your reference, you can try the suggestion as mentioned below,

https://salesforce.stackexchange.com/questions/72261/how-do-i-fetch-all-the-folders-in-salesforce-using-rest-api

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.


Thanks.

 
AnudeepAnudeep (Salesforce Developers) 
You can use the REST API to retrieve the attachments. Use workbench or postman and do a GET to the following URL
https://your_instance/services/data/v43.0/query?q=select id, LinkedEntityId,ContentDocumentId from ContentDocumentLink where LinkedEntityId = '003xxxxxxxxxx'

ContentDocumentId field in ContentDocumentLink stores the file references associated with the parent entity. ContentDocument stores the file relationships & references, while ContentVersion object stores the versions and the file-content references

Anudeep
This was selected as the best answer
KJ1122KJ1122
Thanks Anudeep. before making the call via postman. Do i need to expose the Apex rest service in Salesforce dev console? Also,how is the authorization handled? Thanks!!
AnudeepAnudeep (Salesforce Developers) 
If you are making the call via postman follow this blog to learn how authorization is taken care of. Thanks
Megan HumbertMegan Humbert
The Proxy Bay maintains a number of places offering links to The Pirate Bay. Such pirate bay proxy servers are hosted in countries where there is no blockade of The Pirate Bay. More information is available on the blocks at Torrentfreak. Pirate Proxy (https://www.techmediabooks.com/pirate-bay-proxy-sites-list-to-unblock-pirate-bay/) sites are simplest ways of bypassing the barrier. For other means of accessing The Pirate Bay, search the Alternative methods.
KJ1122KJ1122
Hi, Is there a way to not use oauth 2.0 and use any other custom mechanism in the connected APP to get the access token?
https://crmcog.com/how-to-call-salesforce-rest-apis/
rajat tyagi 14rajat tyagi 14
Thank you for sharing this useful information. Getting the right sarkariexam (https://newgovjobs.in) information at the right time is very crucial if you are preparing for your job exams. Thanks once again for such a nice discussion here.
Ella veElla ve
Fancy text symbols (https://www.symbolspy.com/) online for you, when you are coding.
daniel hunterdaniel hunter
the best answer is the solution for this topic I believe so check John Deere 750 (https://tractordir.com/john-deere-750-deep-review/) for more read
Nancy BatesNancy Bates
Thanks for the information about rest api, with android mdm (https://scalefusion.com/features), secure & manage Android devices for heightened employee productivity. Streamline usage restrictions & policies to ensure the security of critical corporate data.
Gloria PrebleGloria Preble
Copy and paste symbols https://www.symbolcopy.com/ using this tool is so handy.
Lori AlexanderLori Alexander
Grab your cute Lenny faces to show your emotions https://www.lennyfac.es/
James Lee 96James Lee 96
Nowadays, people do a number of tasks online with the help of the internet. When they connect their device to the internet, it becomes open to web-based threats. Be it login details or passwords, much of your data is stored online. Hackers can access your device and steal sensitive details, and may land you in big trouble. To protect your device from such online threats, you need an advanced antivirus program. McAfee does a great job of securing your device from web-based threats lurking in the online world. To get started with McAfee, you can visit mcafee.com/activate (https://mca2fee.com).
Julia AdamsJulia Adams
The Microsoft Office suite was first revealed in 1988 and released two years later in 1990. In the beginning, there were only three leading apps: PowerPoint, Word, and Excel. However, the MS Office Suite's number of applications has evolved from three to several other over time.
https://us3office.com
anup dubeyanup dubey
Thanks anudeep for providing the best answer for this question. schemes (https://schemes.praxisconsultants.in)
Stacy RogersStacy Rogers
Thank you for showing me the flip side of the coin. Very useful information just the way Mconnect Solutions shares.
Veronica JacksonVeronica Jackson
Thanks for the sharing such a nice content. https://www.aestheticsymbols.me/