2 个回答
Hi Michael,
For RESTful checkout the following piece from the docs, specifically the "Inserting a ContentVersion" part
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm
You can ignore the ContentDocumentId attribute, in such case it will create a new one.
This call will generate the ContentVersion record (which olds the binary) and the parent ContentDocument, you'll then need to create the ContentDocumentLink record (in a separate call) that relates the ContentDocument with the sObject record you wish to related it to
https://developer.salesforce.com/docs/atlas.en-us.sfFieldRef.meta/sfFieldRef/salesforce_field_reference_ContentDocumentLink.htm
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm
Another option may be to use the Composite API, specifically the sObject Tree endpoint and make all in a single call, although I've never tried it with Files to determine if is feasible
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobject_tree.htm