Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am following docusign's tutorial to create an envelope using their PHP API. Tutorialis found here: http://www.docusign.com/developer-center/quick-start/request-signatures

I copied the code and downloaded the sample file, and am now getting this response: "errorCode": "UNSPECIFIED_ERROR", "message": "Buffer cannot be null.\r\nParameter name: buffer"

I think the error may be related to this section:

$requestBody = "\r\n"
."\r\n"
."--myboundary\r\n"
."Content-Type: application/json\r\n"
."Content-Disposition: form-data\r\n"
."\r\n"
."$data_string\r\n"
."--myboundary\r\n"
."Content-Type:application/pdf\r\n"
."Content-Disposition: file; filename=\"document.pdf\"; documentid=1 \r\n"
."\r\n"
."$file_contents\r\n"
."--myboundary--\r\n"
."\r\n";

The problem, i think, is that $data_string is not defined anywhere in their example. There is a data definition:

$data = "{
\"emailBlurb\":\"This comes from PHP\",
\"emailSubject\":\"API Signature Request\",
\"documents\":[
{
\"documentId\":\"1\",
\"name\":\"document.pdf\"
}
],
\"recipients\":{
\"signers\":[
{
\"email\":$email,
\"name\":$name,
\"recipientId\":\"1\",
\"tabs\":{
\"signHereTabs\":[
{
\"xPosition\":\"100\",
\"yPosition\":\"100\",
\"documentId\":\"1\",
\"pageNumber\":\"1\"
}
]
}
}
]
},
\"status\":\"sent\"
}";

....But not $data_string.

I tried using the "TEST" as the value for $data_string and got: "errorCode": "INVALID_MULTI_PART_REQUEST", "message": "An error was found while parsing the multipart request. The JSON data in the first part of the multi-part request does not match the expected format. The token 'true' was expected but found 'test'."

I then set the value of $data_string as a boolean (TRUE) and got the following error message: errorCode": "INVALID_MULTI_PART_REQUEST", "message": "An error was found while parsing the multipart request. The JSON data in the first part of the multi-part request does not match the expected format. "

Any help in resolving this is greatly appreciated.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

All you have to do is change $data_string to $data in your code...

Thanks for catching this, I've updated the Gist on the Request Signature page, it should work now.

share|improve this answer
 
It's been confirmed that this sample Gist works now, can you please accept this answer? It works out of the box now. referred to Gist –  Ergin Jul 1 '13 at 21:36
add comment

Yes, this is a bug. I am working on creating a sensible PHP class file derived from that sample code. Here is a class derived from that code which works and is a little cleaner: https://github.com/sylnsr/esign-samples/tree/master/docusign/php -- If you are interested in exploring something other than DocuSign, please feel free to check-in on that project from time to time for other samples for other vendors such as RightSignature which I will be working on next.

share|improve this answer
 
P.S. I also added a check to make sure that the Document ID is a GUID or an integer. I noticed that the service returns an error message if you try to use something like "Recipient 1" for the "recipientId" in the JSON –  Michael.M Jun 20 '13 at 23:38
 
FYI DocuSign has released Java and PHP client libraries for their REST API. See here: github.com/docusign/eSignPHPLib –  Ergin Oct 9 '13 at 23:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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