0

URL I am using: https://mydomain--stg1.my.salesforce.com/services/data/v57.0/sobjects/ContentVersion

I am passing headers like:

enter image description here

Then I have created a json file as mentioned in : https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm

Here is the file I have named as "NewContentVersion.json" and I am uploading it as binary body attachment :

--boundary_string Content-Disposition: form-data; name="entity_content"; Content-Type: application/json

{"Title":"test","PathOnClient":"test.pdf","FirstPublishLocationId":"5008I0000062dqV"}

--boundary_string Content-Type: application/octet-stream Content-Disposition: form-data; name="VersionData"; filename="test.pdf"

255044462d312e370d0a25a1b3c5d70d0a312030206f626a0d0a3c3c2f5061676573203220302052202f547970652f436174616c6f673e3e0d0a656e646f626a0d0a322030206f626a0d0a3c3c2f436f756e7420322f4b6964735b2034203020522020333520302052205d2f547970652f50616765733e3e0d0a656e646f626a0d0a332030206f626a0d0a3c3c2f4372656174696f6e4461746528443a3230323330333331313630373535292f43726561746f722850444669756d292f507262031203020520d0a2f496e666f2033203020520d0a2f53697a652033372f49445b3c31414239384435464141373536444538463338333037334241354345444337303e3c31414239384435464141373536444538463338333037334241354345444337303e5d3e3e0d0a7374617274787265660d0a3136323534390d0a2525454f460d0a......and so on (Base64 encoded string) --boundary_string--

enter image description here

-------------------------xxxxxxxxxxxxxxxxx--------------------------------------------

Updating question based on SfdcFox comment, I am using dcode.fr/file-data#f1 "Binary 00000000-11111111" file reader option to get binary data like "00100101 01010000 01000100 01000110 and so on". But what parameters i need to pass in form-data? :

enter image description here

1 Answer 1

1

Use the form-data option for the body instead of binary. Your data isn't corrupted, simply encoded--you're trying to use hex-encoded data instead of binary data, which isn't supported. The data must be uploaded in binary form.


In Postman, your request should look something like this:

Example of uploading file

6
  • Hi @sfdcfox, I am using dcode.fr/file-data#f1 "Binary 00000000-11111111" fild reader option to get binary data like "00100101 01010000 01000100 01000110 and so on". But what parameters i need to pass in form-data?
    – Rabb
    Apr 17 at 12:18
  • I updated the question with, please check after "-------------------------xxxxxxxxxxxxxxxxx--------------------------------------------"
    – Rabb
    Apr 17 at 12:21
  • 2
    @Rabb When you're using Binary in Postman, you must literally paste binary data. It is not encoded as base-64, hexadecimal, binary, or anything else. In other words, the first five characters you should see in the VerionData area would be %PDF-, as that is what a PDF would look like. You would have unprintable characters in your payload, which is why you can't use the binary option very easily. Use form-data for the Body, and select the file you want to upload.
    – sfdcfox
    Apr 17 at 12:25
  • @Rabb I added an image to help describe what your file upload should look like. When you hover over VersionData, you'll it it says "Text", you need to use that dropdown to change it to "File". Also, you need to use the triple-dot menu on the top-right (next to Bulk Edit in my screenshot) to add the Content-Type.
    – sfdcfox
    Apr 17 at 12:35
  • Thanks @sfdcfox, sorry closing the question 2 days later as I got corona. I tried the way you showed and i was able to upload 200MB file which using composite api provided by salesforce in their docs, i couldn't upload. But that i will see am I doing some mistake their or i will ask create another question. Closing this one. Thanks !
    – Rabb
    Apr 20 at 13:42

You must log in to answer this question.

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