[SalesForce] How tonsert or Update Blob Data using Workbench

Bascially I'm trying to execute the example given here for the upload of Blob Data from Workbench. but on executing I'm getting below error:

message: Unexpected character ('C' (code 67)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [line:2, column:2]
errorCode: JSON_PARSER_ERROR

I'm not sure how to execute it from workbench.

This is what I put in request body:

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

{
    "allOrNone" : false,
    "records" :
    [
        {
            "attributes" :
            {
                "type" : "Document",
                "binaryPartName": "binaryPart1",
                "binaryPartNameAlias": "Body"
            },
            "Description" : "Marketing Brochure",
            "FolderId" : "005xx000001Svs4AAC",
            "Name" : "Brochure",
            "Type" : "pdf"
        },
        {
            "attributes" :
            {
                "type" : "Document",
                "binaryPartName": "binaryPart2",
                "binaryPartNameAlias": "Body"
            },
            "Description" : "Pricing Overview",
            "FolderId" : "005xx000001Svs4AAC",
            "Name" : "Pricing",
            "Type" : "pdf"
        }
    ]
}

--boundary_string
Content-Disposition: form-data; name="binaryPart1"; filename="Brochure.pdf"
Content-Type: application/pdf

Binary data goes here.

--boundary_string
Content-Disposition: form-data; name="binaryPart2"; filename="Pricing.pdf"
Content-Type: application/pdf

Binary data goes here.

--boundary_string--

After adding only JSON in request body I'm able to create file in sfdc but those files are empty, how to send data?

Best Answer

You need to specify the Content-Type header that the example shows (given to curl with the -H flag) within Workbench, so that Salesforce knows it's receiving a multipart/form-data request body, rather than pure JSON.

In Workbench, click Headers to access this data entry:

enter image description here

You need to provide the

Content-Type: multipart/form-data; boundary="boundary_string"

header so Salesforce doesn't try to parse the entire body as JSON, which it isn't.

Related Topic