Docusignapi DocuSign PUT resend_信封=真
我正在开发与docusignrestapi接口的东西。发送和作废信封工作正常,但我在尝试重新发送信封时遇到问题 我收到了对PUT调用(如下)的错误请求状态响应,目的是1)更正错误的电子邮件地址或2)强制重新发送,因为客户端输入了错误的访问代码,并将信封置于身份验证失败状态 这是我在创建请求时与PUT方法一起使用的url(在我的live应用程序中适当地替换了accountId和EnvelopedId):Docusignapi DocuSign PUT resend_信封=真,docusignapi,Docusignapi,我正在开发与docusignrestapi接口的东西。发送和作废信封工作正常,但我在尝试重新发送信封时遇到问题 我收到了对PUT调用(如下)的错误请求状态响应,目的是1)更正错误的电子邮件地址或2)强制重新发送,因为客户端输入了错误的访问代码,并将信封置于身份验证失败状态 这是我在创建请求时与PUT方法一起使用的url(在我的live应用程序中适当地替换了accountId和EnvelopedId): https://demo.docusign.net/restapi/v2/accounts/{
https://demo.docusign.net/restapi/v2/accounts/{accountId}/envelopes/{envelopeId}/recipients?resend_envelope=true
创建请求后(出于测试目的),我立即写出请求头,如下所示:
X-DocuSign-Authentication: <DocuSignCredentials><Username>omitted</Username><Password>omitted</Password><IntegratorKey>omitted</IntegratorKey></DocuSignCredentials>
Accept: application/xml
Content-Type: application/xml
Host: demo.docusign.net
X-DocuSign-Authentication:省略
接受:应用程序/xml
内容类型:application/xml
主机:demo.docusign.net
请求主体如下所示。请注意,正如DocuSign支持人员所建议的那样,我有几个版本,有xmlns属性和没有xmlns属性,有签名者节点和没有签名者节点
<signers>
<signer>
<name>FName LName</name>
<email>emailaddr@fake.com</email>
<recipientId>1</recipientId>
</signer>
</signers>
FName LName
emailaddr@fake.com
1.
我得到的错误请求响应如下,响应中的实际信封ID与我的重发请求匹配
<envelopeSummary xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><envelopeId>omitted</envelopeId><status>bad request</status><statusDateTime>6/5/2015 2:41:04 PM</statusDateTime></envelopeSummary>
省略错误请求2015年5月6日下午2:41:04
DocuSign支持部门已对上述所有内容进行了审查,但他们无法就重发请求失败的原因提供任何意见。支持人员说,他们看到的不是PUT调用,而是在信封ID之前结束的POST。毫无意义
如果您能提供任何有关问题的反馈,我将不胜感激。谢谢
*****我改为以json格式发送请求正文,并成功地更新了信封的电子邮件地址。但是,这并没有触发重新发送
*****出于好奇,我又重新发送了一次信封,很高兴它被人憎恨。奇怪的是,第一个PUT执行了更正(将错误的电子邮件地址更改为更正的电子邮件地址),但没有导致重新发送信封。第二个PUT在重新发送时起作用(没有任何更改)。这是为我设计的,这里有一个完整的工作解决方案,它从模板创建一个新信封,发送它,然后对该正在运行的信封执行更正。我得到返回的成功状态,并在控制台中查看更新的收件人信息
<?php
// Input your info here:
$email = "***"; // your account email (also where this signature request will be sent)
$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
// 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
echo "\naccountId = " . $accountId . "\nbaseUrl = " . $baseUrl . "\n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Create an envelope from a template and send
/////////////////////////////////////////////////////////////////////////////////////////////////
$data = array("accountId" => $accountId,
"emailSubject" => "DocuSign API - Signature Request from Template",
"templateId" => $templateId,
"templateRoles" => array(
array( "recipientId" => "1234", "email" => $email, "name" => $recipientName, "roleName" => $templateRoleName )),
"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- Status returned = " . $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";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 3 - Perform correction and resend envelope
/////////////////////////////////////////////////////////////////////////////////////////////////
echo "Performing envelope correction...\n";
$data_string =
"{
\"signers\" :
[
{
\"email\": \"new_email_address\",
\"name\": \"new_recipient_name\",
\"recipientId\": \"1234\"
}
]
}";
$curl = curl_init($baseUrl . "/envelopes/$envelopeId/recipients" . "?resend_envelope=true" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
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 != 200 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
// --- display results
echo "Correction result = " . "\n\n" . $json_response. "\n\n";
?>
请尝试添加收件人块:FName LNameemailaddr@fake.com我同意这是一个PUT而不是POST。信封更正对我来说很好,尽管我只使用JSON格式而不是XML进行了测试。我将发布一个完整的PHP工作解决方案,因为我不确定您使用的是什么语言。作为一个测试,请尝试更改为JSON正文,看看这是否是XML的问题。。。