i have created a master account manually on docusign and now i want to create new users using this account. This is my code:
$integratorKey = 'XXXX-XXXXX-XXXX-XXXX-XXXX-XXXXXXXX';
$email = 'my-email';
$password = 'XXXX';
$name = 'User';
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
$data = '{
"newUsers":[{
"activationAccessCode":"",
"email":"my-email#gmail.com",
"enableConnectForUser":"",
"firstName":"",
"forgottenPasswordInfo":{
"forgottenPasswordAnswer1":"",
"forgottenPasswordAnswer2":"",
"forgottenPasswordAnswer3":"",
"forgottenPasswordAnswer4":"",
"forgottenPasswordQuestion1":"",
"forgottenPasswordQuestion2":"",
"forgottenPasswordQuestion3":"",
"forgottenPasswordQuestion4":""
},
"groupList":{
"groupId":"",
"groupId":""
},
"lastName":"",
"middleName":"",
"password":"",
"sendActivationOnInvalidLogin":"",
"suffixName":"",
"title":"",
"userName":"username",
"userSettings":[{
"name":"",
"value":""
}]
}]
}';
$requestBody = "\r\n"
."\r\n"
."--myboundary\r\n"
."Content-Type: application/json\r\n"
."Content-Disposition: form-data\r\n"
."\r\n"
."$data\r\n"
."--myboundary--\r\n"
."\r\n";
$url = "https://demo.docusign.net/restapi/v2/accounts";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($requestBody),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
var_dump($response);
The error that i am getting is this : { "errorCode": "INVALID_REQUEST_BODY", "message": "The request body is missing or improperly formatted. Input string was not in a correct format." }. Could anyone tell me what is the issue?
Developer had an issue with the json format. There were unwanted values that got removed and it's now working (Based on comments above). Making sure this is marked as answered.
Related
I am having a problem getting the below code to work in my developer account. I keep getting the following error:
"ERROR calling webservice, status is:400 error text is --> { "errorCode": "ENVELOPE_IS_INCOMPLETE", "message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line." }"
Anyone have an idea why this error is occuring? The "test.pdf" is located in the same directory as the docusign.php file that is the below code:
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Establish Credentials & Variables
/////////////////////////////////////////////////////////////////////////////////////////////////
// Input your info here:
$name = "John P. Doe"; //The user from Docusign (will show on the email as the sender of the contract)
$email = " MY EMAIL ACCOUT USED FOR DOCUSIGN ";
$password = " MY PASSWORD FOR DOCUSIGN "; // The password for the above user
$integratorKey = " MY API KEY FOR DEMO ";
// construct the authentication header:
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 3 - Login (to retrieve baseUrl and accountId)
/////////////////////////////////////////////////////////////////////////////////////////////////
$url = "https://demo.docusign.net/restapi/v2/login_information";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "ERROR:<BR>";
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);
// --- display results
// echo "\naccountId = " . $accountId . "\nbaseUrl = " . $baseUrl . "\n";
echo "Document is being prepared. Please stand by.<br>Do not navigate away from this page until sending is confirmed.<br><br>";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 4 - Create an envelope using composite templates
/////////////////////////////////////////////////////////////////////////////////////////////////
$data_string =
"
{
\"status\":\"sent\",
\"emailSubject\":\"Test transforming pdf forms and assigning them to each user\",
\"emailBlurb\":\"Test transforming pdf forms and assigning them to each user\",
\"compositeTemplates\":[
{
\"inlineTemplates\":[
{
\"sequence\": \"1\",
\"recipients\":{
\"signers\":[
{
\"email\":\"test1#test.com\",
\"name\":\"Signer One\",
\"recipientId\":\"1\",
\"routingOrder\":\"1\",
\"tabs\":{
\"textTabs\":[
{
\"tabLabel\":\"PrimarySigner\",
\"value\":\"Signer One\"
}
]
}
},
{
\"email\":\"test2#test.com\",
\"name\":\"Signer Two\",
\"recipientId\":\"2\",
\"routingOrder\":\"2\",
\"tabs\":{
\"textTabs\":[
{
\"tabLabel\":\"SecondarySigner\",
\"value\":\"Secondary One\"
}
]
}
}
]
}
}
],
\"document\": {
\"documentId\": \"1\",
\"name\": \"test.pdf\",
\"transformPdfFields\": \"true\"
}
}
]
}
";
$curl = curl_init($baseUrl . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "ERROR calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];
// --- display results
echo "Document is sent!<br> Envelope: " . $envelopeId . "\n\n";
From what I can tell, the actual PDF Bytes of test.pdf are not being sent as part of this API request - therefore the error message is calling out the fact that you are referencing a document which is missing. Take a look at the PHP recipe examples for how you can read the PDF bytes in from a file and include it in your API request:
https://www.docusign.com/developer-center/recipes/request-a-signature-via-email
Specifically, this line and variable: $file_contents = file_get_contents($documentFileName);
I have a web app that takes a user through a series of forms and then generates a pdf with their answers. I want to add a Docusign signature to the end of the pdf form, so that after finishing the online form they are asked to sign it in an iframe.
I started with this doc - https://www.docusign.com/developer-center/recipes/signing-from-your-app and then took step 2 from this doc to create my envelope with a document - https://www.docusign.com/developer-center/recipes/request-a-signature-via-email
My code created the Envelope ID fine, but when I try to get the URL using /envelopes/$envelopeId/views/recipient I get the status 400 error:
{ "errorCode": "ACCOUNT_NOT_AUTHORIZED_FOR_ENVELOPE", "message": "This account is not authorized to access the requested envelope." }
Here is my full code below:
<?php
$docusign_username = "my#username.com";
$docusign_password = "mypassword";
$docusign_integrator_key = "my-integrator-key";
$applicant_email = "johnsmith#emailaddress.com";
$applicant_name = "John Smith";
$applicant_unique_id = "123";
$application_unique_id = "31587";
$application_form_pdf = "31587.pdf";
// construct the authentication header:
$header = "<DocuSignCredentials><Username>" . $docusign_username . "</Username><Password>" . $docusign_password . "</Password><IntegratorKey>" . $docusign_integrator_key . "</IntegratorKey></DocuSignCredentials>";
//////////////////////////////////////////////////////////////////////////////////////
// STEP 1 - Login (retrieves baseUrl and accountId)
//////////////////////////////////////////////////////////////////////////////////////
$url = "https://demo.docusign.net/restapi/v2/login_information";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);
//--- display results
echo "accountId = " . $accountId . "\nbaseUrl = " . $baseUrl . "\n";
//////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Create an envelope with document
//////////////////////////////////////////////////////////////////////////////////////
$data =
array (
"emailSubject" => "DocuSign API - Please sign " . $application_form_pdf,
"documents" => array(
array("documentId" => $application_unique_id, "name" => $application_form_pdf)
),
"recipients" => array(
"signers" => array(
array(
"email" => $applicant_email,
"name" => $applicant_name,
"clientUserId" => $applicant_unique_id,
"recipientId" => $applicant_unique_id,
"tabs" => array(
"signHereTabs" => array(
array(
"xPosition" => "100",
"yPosition" => "100",
"documentId" => $application_unique_id,
"pageNumber" => "1"
)
)
)
)
)
)
, "status" => "sent"
// , "status" => "created"
);
$data_string = json_encode($data);
$file_contents = file_get_contents($application_form_pdf);
// Create a multi-part request. First the form data, then the file content
$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=\"$application_form_pdf\"; documentid=".$application_unique_id." \r\n"
."\r\n"
."$file_contents\r\n"
."--myboundary--\r\n"
."\r\n";
// Send to the /envelopes end point, which is relative to the baseUrl received above.
$curl = curl_init($baseUrl . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data;boundary=myboundary',
'Content-Length: ' . strlen($requestBody),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl); // Do it!
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "Error calling DocuSign, status is:" . $status . "\nerror text: ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];
//--- display results
echo "Envelope created! Envelope ID: " . $envelopeId . "\n";
//////////////////////////////////////////////////////////////////////////////////////
// STEP 3 - Get the Embedded Signing View
//////////////////////////////////////////////////////////////////////////////////////
$data = array(
"returnUrl" => "https://www.docusign.com/devcenter"
, "authenticationMethod" => "None"
, "authenticationInstant" => "None"
, "userId" => $applicant_unique_id
, "clientUserId" => $applicant_unique_id
// , "email" => $applicant_email
// , "userName" => $applicant_name
);
$data_string = json_encode($data);
$curl = curl_init($baseUrl."/envelopes/$envelopeId/views/recipient" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
$url = $response["url"];
//--- display results
echo "Embedded URL is: \n\n" . $url . "\n\nNavigate to this URL to start the embedded signing view of the envelope\n";
?>
Any ideas would be gratefully received, thanks!
When obtaining the recipient view (the signing view), try identifying the signer by just specifying the
"email" => $email, # signer's email
"userName" => $recipientName,
"clientUserId" => $clientUserId
as shown in the embedded signing recipe.
Don't set the userId
Hello friends I am using an HTTP server to access Doucsign. And I am getting server problem
That is server error 400 and errorCode.
INVALID_EMAIL_ADDRESS_FOR_RECIPIENT", "message": "The email address
for the recipient is invalid. The recipient Id follows.
My code is
<?php
// Input your info here:
$email = "****"; // your account email
$password = "*******"; // your account password
$integratorKey = "*********"; // your account integrator key, found on (Preferences -> API page)
$recipientName = "usa usa"; // provide a recipient (signer) name
$documentName = "proposal.pdf"; // copy document with same name into this directory!
// construct the authentication header:
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1 - Login (to retrieve baseUrl and accountId)
/////////////////////////////////////////////////////////////////////////////////////////////////
$url = "https://demo.docusign.net/restapi/v2/login_information";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);
//--- display results
echo "\naccountId = " . $accountId . "\nbaseUrl = " . $baseUrl . "\n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Create an envelope with one recipient, one tab, and one document and send
/////////////////////////////////////////////////////////////////////////////////////////////////
// the following request body will place 1 signature tab on the document you supply, located
// 100 pixels to the right and 100 pixels down from the top left of the document
$data = array (
"emailSubject" => "DocuSign API - Signature Request on Document",
"documents" => array( array( "documentId" => "1", "name" => $documentName)),
"recipients" => array( "signers" => array(
array( "email" => $email,
"name" => $recipientName,
"recipientId" => "1",
"tabs" => array(
"signHereTabs" => array(
array( "xPosition" => "100",
"yPosition" => "100",
"documentId" => "1",
"pageNumber" => "1" )
))
))
),
"status" => "sent"
);
$data_string = json_encode($data);
$file_contents = file_get_contents($documentName);
$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=\"$documentName\"; documentid=1 \r\n"
."\r\n"
."$file_contents\r\n"
."--myboundary--\r\n"
."\r\n";
// *** append "/envelopes" to baseUrl and as signature request endpoint
$curl = curl_init($baseUrl . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data;boundary=myboundary',
'Content-Length: ' . strlen($requestBody),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
echo $status;
if ( $status != 201 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];
//--- display results
echo "Document is sent! Envelope ID = " . $envelopeId . "\n\n";
Can anyone help me? Thanks in advance.
i get this error calling webservice, status is:401 when i made a new account a member account (non developer account and try to integrate it in a form that i have..i based the code from the api walkthroughs in docusign itself
<?php
if(($_POST['submit']))
{
// Input your info here:
$integratorKey = 'XXXX-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX';
$email = 'XXXXXXXXXX';
$email1 = 'XXXXXXXXX';
$email2 = 'XXXXXXXX';
$password = 'XXXXXXXX';
$name = 'XXX';
$name2 = 'XXXXXX';
// construct the authentication header:
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1 - Login (to retrieve baseUrl and accountId)
/////////////////////////////////////////////////////////////////////////////////////////////////
$url = "https://demo.docusign.net/restapi/v2/login_information";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);
//--- display results
/////////////////////////////////////////////////////////////////////////////////////////// //////
// STEP 2 - Create an envelope with one recipient, one tab, one document and send!
/////////////////////////////////////////////////////////////////////////////////////////// //////
$data = "{
\"emailBlurb\":\"This comes from Dateguard\",
\"emailSubject\":\"DocuSign API - Please Sign This Contract for Dateguard...\",
\"documents\":[
{
\"documentId\":\"1\",
\"name\":\"contract.pdf\"
}
],
\"recipients\":{
\"signers\":[
{
\"email\":\"$email1\",
\"name\":\"$name\",
\"recipientId\":\"1\",
\"tabs\":{
\"signHereTabs\":[
{
\"xPosition\":\"80\",
\"yPosition\":\"550\",
\"documentId\":\"1\",
\"pageNumber\":\"1\"
}
]
}
},
{
\"email\":\"$email2\",
\"name\":\"$name2\",
\"recipientId\":\"2\",
\"tabs\":{
\"signHereTabs\":[
{
\"xPosition\":\"400\",
\"yPosition\":\"550\",
\"documentId\":\"1\",
\"pageNumber\":\"1\"
}
]
}
}
]
},
\"status\":\"sent\"
}";
$file_contents = file_get_contents("contract.pdf");
$requestBody = "\r\n"
."\r\n"
."--myboundary\r\n"
."Content-Type: application/json\r\n"
."Content-Disposition: form-data\r\n"
."\r\n"
."$data\r\n"
."--myboundary\r\n"
."Content-Type:application/pdf\r\n"
."Content-Disposition: file; filename=\"contract.pdf\"; documentid=1 \r\n"
."\r\n"
."$file_contents\r\n"
."--myboundary--\r\n"
."\r\n";
// *** append "/envelopes" to baseUrl and as signature request endpoint
$curl = curl_init($baseUrl . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data;boundary=myboundary',
'Content-Length: ' . strlen($requestBody),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];
//--- display results
$home_url = 'thanks.php';
header('Location: ' . $home_url);
}
?>
now the problem is when i use my developer account in docusign as credentials for the api it works but when i create a member account it does not( the free trial )..is it supposed to work that way?am i missing something? if it is then how am i supposed to use the api to work so that a member use their own account and use their own credentials and be able to use it in docusign api and not my own developer account because of the "test" indication. thanks in advance.
401 Authorization Required
If the code is good with developer account, then the reason should be the account privilege.
The API is not enabled on DocuSign free-trial accounts - it's enabled on free developer sandbox accounts (which do NOT expire after 30 days). The only way to create those accounts are through the DocuSign Developer Center .
Of course, if you have a live integration, meaning you passed Certification with DocuSign, then you might have a production account which has the api enabled, but while you are developing and testing you can only do so with developer accounts and not the free trials.
Good Day i'm new to this docusignapi integration via PHP curl and i want to try this integration. I've copy the code below from http://iodocs.docusign.com/APIWalkthrough/requestSignatureFromDocument and hoping i can easily test and understand how the integration works. But unfortunately an error always occur "error calling webservice, status is:0". I've tried other work around like changing the header format from XML to JSON but the error still shows up. Please help.
// Input your info here:
$integratorKey = 'XXXX-9999X9XX-X999-9999-99X9-9X9999X9XX9X';
$email = 'name#domain.com';
$password = 'samplepassword';
$name = 'Sender Full Name';
// construct the authentication header:
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1 - Login (to retrieve baseUrl and accountId)
/////////////////////////////////////////////////////////////////////////////////////////////////
$url = "https://demo.docusign.net/restapi/v2/login_information";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
print_r(curl_getinfo($curl));
echo "<br/>";
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);
//--- display results
echo "\naccountId = " . $accountId . "\nbaseUrl = " . $baseUrl . "\n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Create an envelope with one recipient, one tab, and one document and send
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array (
"emailBlurb" => "This comes from PHP",
"emailSubject" => "API Signature Request",
"documents" => array(array( "documentId" => "1", "name" => "testDS.pdf")),
"recipients" => array( "signers" => array(
array( "email" => $email,
"name" => $name,
"recipientId" => "1",
"tabs" => array(
"signHereTabs" => array(
array(
"xPosition" => "100",
"yPosition" => "100",
"documentId" => "1",
"pageNumber" => "1"
)
)
)
)
)
),
"status" => "sent");
$data_string = json_encode($data);
$file_contents = file_get_contents("testDS.pdf");
$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=\ātestDS.pdf\"; documentid=1 \r\n"
."\r\n"
."$file_contents\r\n"
."--myboundary--\r\n"
."\r\n";
// *** append "/envelopes" to baseUrl and as signature request endpoint
$curl = curl_init($baseUrl . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data;boundary=myboundary',
'Content-Length: ' . strlen($requestBody),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];
//--- display results
echo "Document is sent! Envelope ID = " . $envelopeId . "\n\n";
Is there any possibilities that my integratorkey is not valid? if yes, is there any way for me to check if my integrator key is valid or not?
In creating my integratorkey i just followed the procedure in this link http://www.docusign.com/developer-center/quick-start/first-api-call
I can't see anything wrong with the code right away. Whenever no status is returned at all it's usually one of three things that may be causing this:
Security software stopping your request from going through.
A Firewall stopping your request from going through.
Port 443 being closed for some other reason (other than 2 or 3).
Do you have any logs you can check to see if your requests are being intercepted, either at the software level or hardware level (if you have a hardware firewall)? I'd start by checking things like that.