You need to sign in to do that
Don't have an account?
Radha Rathinavel Pandian
how to fetch my content of my document
Hi,
I need to fetch my content of my document which is uplaoded to the attachment.
I need to pass the query in REST API through workbench
So far I tried , Select id,ContentDocumentId,ContentDocument.LatestPublishedVersionId from ContentDocumentLink where LinkedEntityId IN ('a011I00000D55nx') , This gives the result as url,
Anyone of them pleae let me know how to get the body of the file?
I need to fetch my content of my document which is uplaoded to the attachment.
I need to pass the query in REST API through workbench
So far I tried , Select id,ContentDocumentId,ContentDocument.LatestPublishedVersionId from ContentDocumentLink where LinkedEntityId IN ('a011I00000D55nx') , This gives the result as url,
Anyone of them pleae let me know how to get the body of the file?
Run a REST GET request hitting this url. It should give you the file content. You can try this via WORKBENCH, which downloads your file. If you try the same using REST API call in apex, it should give you the body of the file.
Give a try and see if it works.
Sample Http REST request is below. Replace the Id of the ContentVersion in below code and it returns you the file body.
- Harsha
All Answers
Run a REST GET request hitting this url. It should give you the file content. You can try this via WORKBENCH, which downloads your file. If you try the same using REST API call in apex, it should give you the body of the file.
Give a try and see if it works.
Sample Http REST request is below. Replace the Id of the ContentVersion in below code and it returns you the file body.
- Harsha
Can I have the version data(BLOB) in workbench without using code that you have given.
- Harsha
There is another approach by using only queries.
You can use ContentNote. Use quer like below:
recId = Id of the related record e.g. Case
Id contentDocId = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = 'recId '];
ContentNote cn = [ select id,Title,CreatedDate, Content,TextPreview from ContentNote Where Id = 'contentDocId' ]; // gives value of note body and title
The TextPreview field will give you the value of the note Content.
Thanks
Ranjit
What would be the format of the response body from '/services/data/v42.0/sobjects/ContentVersion/06890000003oTkqAAE/VersionData' REST service?
I am trying to fetch few pdf and xls files from SFDC org1 and store it in SFDC org2. I could get the contentversion versondata body using the service '/services/data/v42.0/sobjects/ContentVersion/06890000003oTkqAAE/VersionData'. But I am not sure what is the format of the response and how to store it in SFDC org2. I tried the below code, it creates pdf and xls files but the files are corrupted.