+ Start a Discussion
Abhijit Shrikhande 10Abhijit Shrikhande 10 

How can I test the REST API for documents using workbench?

I wish to understand how the REST API works with document attachments. I found some links
http://www.salesforce.com/us/developer/docs/api_rest/index.htm
http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert_update_blob.htm

Using this information, I wanted to test this in the workbench REST Explorer. So I composed the following request:
{  
    "Description" : "Marketing brochure for Q1 2011",
    "Keywords" : "marketing,sales,update",
    "FolderId" : "00l70000001AG5g",
    "Name" : "Marketing Brochure Q1",
    "Type" : "pdf"
}

--boundary_string
Content-Type: application/pdf
Content-Disposition: form-data; name="Body"; filename="2011Q1MktgBrochure.pdf"
%PDF-1.4
%âãÏÓ
519 0 obj
<</Linearized 1/L 855529/O 521/E 35857/N 12/T 845101/H [ 894 565]>>
endobj
             
xref
519 29
0000000016 00000 n
0000001647 00000 n
0000001459 00000 n
0000000894 00000 n
trailer
<</Size 548/Prev 845089/XRefStm 1459/Root 520 0 R/Info 124 0 R/ID[<097E027FBE8C884598F32EB7C237FF5B><4080463A838922439FB92E5A73905FAB>]>>
startxref
0
%%EOF
             
547 0 obj
<</Length 476/C 591/Filter/FlateDecode/I 615/S 450>>stream
xÚb```f``¹ÀÀÊÀ ¦Ï Ì€

--boundary_string--


When I attempt to execute this using REST API - /services/data/v29.0/sobjects/Document
using the POST method, I get this error:
JSON_PARSER_ERROR
message: Extra JSON in request found after deserialization at: [line:9, column:3]
errorCode: JSON_PARSER_ERROR


I wish to know how can I test this in the Rest Explorer
EnreecoEnreeco
I think you missed the beginning part of the request body; something like
--boundary_string
Content-Type: application/json

.... json content
... the rest of the response