0

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?

  • What did you set the content type to on your workbench request? Looks like you may have declared JSON data but sent multipart. – David Reed Jan 22 at 11:22
  • I have added the body which I set – salesforce Developer Jan 22 at 11:54
3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.