cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to post mixed content using rest post snap?

Mihir
New Contributor II

I have a use case to upload a file (size > 50MB) to Salesforce. As Salesforce snappack supports file upload upto 50MB file so to upload file of size more than 50MB we need to use multipart form data request.

One part of request should be non-binary data and other part is binary data (file content) like below:

โ€“boundary_string
Content-Disposition: form-data; name=โ€œentity_contentโ€;
Content-Type: application/json

{
โ€œContentDocumentIdโ€ : โ€œ069D00000000so2โ€,
โ€œReasonForChangeโ€ : โ€œMarketing materials updatedโ€,
โ€œPathOnClientโ€ : โ€œQ1 Sales Brochure.pdfโ€
}

โ€“boundary_string
Content-Type: application/octet-stream
Content-Disposition: form-data; name=โ€œVersionDataโ€; filename=โ€œQ1 Sales Brochure.pdfโ€

Binary data goes here.

โ€“boundary_stringโ€“

Can someone help me how to achieve this in rest post snap?

Thanks,
Mihir

4 REPLIES 4

SpiroTaleski
Valued Contributor

@Mihir

I can see that this is related with the ContentVersion object in Salesforce(correct me if I am wrong).

Instead of using Rest Post Snap, check with the Salesforce Create Snap. The Snap supports the ContentVersion object.

image

Regards,
Spiro Taleski

Mihir
New Contributor II

@Spiro_Taleski
I tried using Salesforce Create snap with ContentVersion object but it is has a limitation of uploading 50Mb of text file or 37Mb of binary file. But I have upload a file whose size can vary upto ~250Mb.

Thanks,
Mihir

SpiroTaleski
Valued Contributor

@Mihir

I was not aware about that limitation. Did the snap fail if you try to upload content greater than 50MB/37MB?

I am not very familiar with the Salesforce APIโ€™s, but you can try to send below sample as a body of the request (by replacing with your data):

{
    "ContentDocumentId": "069D00000000so2",
    "ReasonForChange": "Marketing materials updated",
    "PathOnClient": "Q1 Sales Brochure.pdf",
	"VersionData": "your binary file data(file content)"
}

And add Content Type = multipart/form-data, as a header of the request:

image

Regards,
Spiro Taleski

Mihir
New Contributor II

Hi @Spiro_Taleski,

Yes, Salesforce will send an error response if you try to upload content greater than 50MB/37MB using Salesforce APIโ€™s.

I have tried as you suggested but it didnโ€™t work. โ˜น๏ธ

Thanks,
Mihir