Docusign API transformPdfFields & php - php

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);

Related

docusign download documents after user sign

I am using docusign-rest-recipes github link to download DOC after user signs.
I am facing following error when I try this code:
"PARTNER_AUTHENTICATION_FAILED .The specified Integrator Key was not found or is disabled. An Integrator key was not specified.".
I have assigned all values correctly, But still I can't get out of this error. Any help is appriciated
<?php
// Input your info here:
$email = "***"; // your account email
$password = "***"; // your account password
$integratorKey = "***"; // your account integrator key, found on (Preferences -> API page)
// copy the envelopeId from an existing envelope in your account that you want
// to download documents from
$envelopeId = "***";
// construct the authentication header:
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</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 - Get document information
/////////////////////////////////////////////////////////////////////////////////////////////////
$curl = curl_init($baseUrl . "/envelopes/" . $envelopeId . "/documents" );
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);
curl_close($curl);
//--- display results
echo "Envelope has following document(s) information...\n";
print_r($response); echo "\n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 3 - Download the envelope's documents
/////////////////////////////////////////////////////////////////////////////////////////////////
foreach( $response["envelopeDocuments"] as $document ) {
$docUri = $document["uri"];
$curl = curl_init($baseUrl . $docUri );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_BINARYTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"X-DocuSign-Authentication: $header" )
);
$data = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
file_put_contents($envelopeId . "-" . $document["name"], $data);
curl_close($curl);
//*** Documents should now be downloaded in the same folder as you ran this program
}
//--- display results
echo "Envelope document(s) have been downloaded, check your local directory.\n";
I have regenerated my $integratorKey again and given 777 permissions to folder where image has to be saved. That $integratorKey was issue, Creating a new one resolved the issue.
Note: You can also get status of DOC by envelope ID, So If status is completed then you can download the DOC.

Embedded document for Signing -Docu sign REST API

I`m using REST api for embedding signing.I want to embedded a document for signing in the website for each user who logged into my website. For this I have created a Template and add some tags and set them as required. While creating the template in the 'Recipients and Routing' section I have provided only one signer email and name. For generating the url for embedded signing I have used the following code
<?php
// Input your info:
$email = "***"; // your account email
$password = "***"; // your account password
$integratorKey = "***"; // your account integrator key, found on (Preferences -> API page)
$recipientName = "***"; // provide a recipient (signer) name
$templateId = "***"; // provide a valid templateId of a template in your account
$templateRoleName = "***"; // use same role name that exists on the template in the console
$clientUserId = "***"; // to add an embedded recipient you must set their clientUserId property in addition to
// the recipient name and email. Whatever you set the clientUserId to you must use the same
// value when requesting the signing URL
// construct the authentication header:
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</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 an Embedded recipient (uses the clientUserId property)
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array("accountId" => $accountId,
"emailSubject" => "DocuSign API - Embedded Signing Example",
"templateId" => $templateId,
"templateRoles" => array(
array( "roleName" => $templateRoleName, "email" => $email, "name" => $recipientName, "clientUserId" => $clientUserId )),
"status" => "sent");
$data_string = json_encode($data);
$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"];
curl_close($curl);
//--- display results
echo "Envelope created! Envelope ID: " . $envelopeId . "\n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 3 - Get the Embedded Singing View
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array("returnUrl" => "http://www.docusign.com/devcenter",
"authenticationMethod" => "None", "email" => $email,
"userName" => $recipientName, "clientUserId" => $clientUserId
);
$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";
?>
And its successfully generate the link. But the problem is that I can`t see the tags I have set in the template, and there is a list of fields in the left side .Is there any additional setting to display the tags in the documents itself for all the users who logged to access the document for signing.
As a follow up here, looks like the issue was due to not matching your recipient to the roleName on the template. For the benefit of the community, whenever you are creating an envelope / requesting a signature from a Template, you need to make sure you specify the same exact roleName in your API request as you gave the template role in the DocuSign Console.

docusign error calling webservice, status is:401

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.

role name in embedded sending docusign

I am using the docusign rest api. I am trying to create a template and then use embedded sending.
Here is my code:
Create a template:
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
$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 ) {
$status = 'notok';
}
$response = json_decode($json_response, true);
if( (isset($response['errorCode'])) && ($response['errorCode'] == 'USER_LACKS_PERMISSIONS')) {
echo $msg = 'This user lacks sufficient permissions';
$_SESSION['msg_frm_apd'] = $msg;
}
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);
$template_name = "template_" . time();
$data = "{
\"emailBlurb\":\"String content\",
\"emailSubject\":\"String content\",
\"documents\": [{
\"documentId\": \"1\",
\"name\": \"document.pdf\"
}],
\"recipients\": {
\"signers\": [{
\"recipientId\": \"1\",
\"roleName\": \"Signer 1\"
}]
},
\"envelopeTemplateDefinition\": {
\"description\": \"Description\",
\"name\": \"$template_name\"
}
}";
$file_contents = file_get_contents("uploads/envelopes/" . $file_name);
$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=\ā€¯document.pdf\"; documentid=1 \r\n"
."\r\n"
."$file_contents\r\n"
."--myboundary--\r\n"
."\r\n";
$url = "https://demo.docusign.net/restapi/v2/accounts/376082/templates";
$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: multipart/form-data;boundary=myboundary',
'Content-Length: ' . strlen($requestBody),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$response = json_decode($json_response, true);
$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);
Embedded Sending:
$templateId = $response['templateId']; // provide a valid templateId of a template in your account
$clientUserId = "1234";
$templateRoleName = "Signer 1";
$data = array("accountId" => $accountId,
"emailSubject" => "DocuSign API - Embedded Sending Example",
"templateId" => $templateId,
"templateRoles" => array(
array( "roleName" => $templateRoleName, "email" => $recipient_email, "name" => $recipient_name, "clientUserId" => $clientUserId )),
"status" => "created");
$data_string = json_encode($data);
$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" ) docusign
);
$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"];
curl_close($curl);
//--- display results
// echo "Envelope created! Envelope ID: " . $envelopeId . "\n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 3 - Get the Embedded Sending View (aka the "tag-and-send" view)
/////////////////////////////////////////////////////////////////////////////////////////////////
/*$data = array("returnUrl" => "http://www.docusign.com/devcenter");*/
$returnUrl = $SITE_URL . "/docusign_return.php";
$data = array("returnUrl" => $returnUrl);
$data_string = json_encode($data);
$curl = curl_init($baseUrl . "/envelopes/$envelopeId/views/sender" );
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);
$response = json_decode($json_response, true);
$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);
}
$url = urlencode($response["url"]);
When i click on the above url, i am getting a page where i can tag and send the document. There is an email address
field in this page which is automatically populated with the $recipient_email. But the problem is that the mail is not going to the recipient email address. Thanks.(also i am not getting any error messages).
There is no problem with your code and it is working perfectly as expected. I can tell that you are using DocuSign's sample code from their API Walkthroughs.
If you're saying everything is working ok and no errors, but that after navigating to the embedded sending URL and sending the document for signature the recipient is not receiving the email I would check for things like security software, spam/junk mail filters, firewalls, etc on your side. The DocuSign service is so widely used that if the emails weren't going out in signature requests there would be a big stink about it pretty quickly, and on top of that I just did a test and my emails are going out just fine.
So as mentioned, if you're sure the email address is correct and you are hitting the SEND button through the UI, I'd check security software, spam/junk mail filters, firewalls, and anything else that might stop the email from arriving on your side.
Another suggestion for troubleshooting issues with email delivery: use DocuSign Connect. If your account is configured properly, you could enable Connect and use the Connect logs to detect if the recipient email is undeliverable (i.e., if DocuSign's receiving a 'bounce-back' when sending to that address).
Create a Custom Connect Configuration in DocuSign, as described in this guide: http://www.docusign.com/sites/default/files/DocuSign_Connect_Service_Guide.pdf.
In the Connect Configuration that you create, you can specify any URL as the URL to publish to -- all you're trying to do for this test is to make Connect send the notification for the "Recipient Sent" event and "Recipient Delivery Failed" event (and create Log entries for the notifications it sends) -- it doesn't matter that the endpoint you specify won't be equipped to receive/process the Connect message.
In the Connect Configuration that you create, be sure to select the options I've highlighted here (as previously stated, you can use any URL -- I just happened to have chosen google.com):
Once you've created and saved the Connect Configuration as described above, go through the process you describe in your question to create/send the Envelope.
Once you've sent the Envelope, login to the DocuSign web console (as Administrator), and view the Connect log entries. (i.e., navigate to Preferences >> Connect >> Logs
You should see log entries listed for each "Recipient Sent" and/or "Recipient Delivery Failed" event that's occurred since the time that you created/enabled the Connect Configuration.
Examining the contents of the log entries should allow you to determine if DocuSign is successfully sending the Recipient email(s), and also whether the Recipient email(s) are bouncing back as undeliverable.
If the log entries indicate that DocuSign is sending the Recipient email(s) and do NOT indicate any bounce-backs, then it's likely an issue with the Email client that's preventing the recipient from receiving the email(s) (as Ergin suggested in his answer).

docusign api create new account

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.

Categories