0

I'm trying to use the REST API to upload a File. Eventually I want to associate this File with a specific account.

I'm following these instructions to upload a binary file, where part of the body looks like:

{  
    "Description" : "Marketing brochure for Q1 2011",
    "Keywords" : "marketing,sales,update",
    "FolderId" : "0017A00000VAQcxQAH",
    "Name" : "Marketing Brochure Q1",
    "Type" : "png"
}

I'm having trouble finding and using a FolderId. In my sandbox (service cloud), I go to App Launcher > Files > Libraries > New Library, and inside of that I create a new folder. I can see the folder here. However, there's no ID for the folder listed, and it's not in the URL.

If I run this SOQL query in a developer console:

SELECT Id, CreatedDate, Name FROM Folder ORDER BY CreatedDate DESC

I can see lots of folders created by other users in my instance, however I don't see my newly created folder, including if I search WHERE Name = 'My New Folder'.

  1. How do I find the Folder ID to associate document uploads with?
  2. Is it possible to upload a document and associate it directly with an Account so it appears in that Account's files tab? I tried passing in "ParentId": "RECORD_ID" but it errors with "No such column 'ParentId' on sobject of type Document".
1
  • Am I missing any permissions on my user?
    – Andy Ray
    Oct 20, 2021 at 15:43

1 Answer 1

0

Instructions you are following is for document object which is classic specific.

in app launcher -. files -> libraries , the available library and folder is for content, not for document.

You should create a content and not a document.
please review the same instructions to upload content version and not document. https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm#inserting_a_contentversion

to link account to that content , 3 objects will be involved.please read about them and implement your logic. objects will be Contentdocument - will represent document https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentdocument.htm

contentversion - different versions of document. one version will be latest with islatest = true. https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentversion.htm

contentdocumentlink will store relation between document and record(Account in your case)

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentdocumentlink.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .