我正在开发与DocuSign REST接口的东西。发送和排尿信封工作正常,但我在试图重新发送信封时遇到了困难。
对于我的PUT调用(下面),我收到了一个错误的请求状态响应(如下所示):( 1)更正错误的电子邮件地址;或( 2)强制重新发送,因为客户端输入了不正确的访问代码并将信封放入身份验证失败状态。
这是我在创建请求时与PUT方法一起使用的url (在我的活动应用程序中适当地替换了accountId和envelopdId ):
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请求体如下所示。注意,正如DocuSign支持所建议的那样,在这里我有几个变体,有和没有xmlns属性,有和没有signer节点。
<signers>
<signer>
<name>FName LName</name>
<email>emailaddr@fake.com</email>
<recipientId>1</recipientId>
</signer>
</signers>我得到的坏请求响应在下面,响应中的实际envelopeId与我的重发请求相匹配。
<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>DocuSign支持已经对上述所有内容进行了审查,但它们无法就重发请求失败的原因提供任何意见。支持说,他们看到的不是PUT调用,而是在envelopeId之前结束的帖子。没有任何意义。
我希望能就问题所在提出任何反馈意见。谢谢
*我改为以json的身份发送我的请求体,并成功地更新了信封的电子邮件地址。然而,这并没有引发新的事件。
*只是出于好奇,我第二次重新打开了信封,很高兴这封信很愤怒。好奇的是,第一次对更正采取了行动(将错误的电子邮件地址更改为更正的电子邮件地址),但并没有引起信封的不满。第二个PUT对重发起作用(没有任何变化)。
发布于 2015-06-11 21:01:01
这是为我准备的,这是一个完整的工作解决方案,它从一个模板创建一个新的信封,发送它,然后它在飞行中的信封上执行一个校正。我获得返回的成功状态,并在控制台中看到更新的收件人信息。
<?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";
?>https://stackoverflow.com/questions/30785920
复制相似问题