[英]Docusign API - trouble with embedded signing
I'm trying to use Embedded Signing in the workflow for users on a site I'm building. 我正在尝试在我正在构建的网站上为用户使用嵌入式签名。 And the error I consistently get (from the API Explorer and through my own code) is: 我一直得到的错误(来自API Explorer和我自己的代码)是:
"errorCode": "RECIPIENT_NOT_IN_SEQUENCE", "message": "The token for an out of sequence recipient cannot be generated." “errorCode”:“RECIPIENT_NOT_IN_SEQUENCE”,“message”:“无法生成无序收件人的令牌。”
First I'm uploading the document to create an envelope and attaching one recipient: 首先,我上传文档以创建信封并附加一个收件人:
$data = array(
'accountId' => $accountId,
'documents' => array(
array(
'documentId' => '1',
'name' => 'document.pdf'
)
),
'recipients' => array(
'signers' => array( array(
array(
'tabs' => array(
'signHereTabs' => array(
array(
"pageNumber" => "1",
"documentId" => "1",
"yPosition" => "100",
"xPosition" => "100",
)
)
)
),
'routingOrder'=> '1',
'recipientId'=> '1',
'clientUserId'=> $clientUserId,
'name'=> 'Signer 1',
'email'=> 'something@gmail.com'
))
)
);
$json_data = json_encode($data);
$file_contents =
file_get_contents("document.pdf");
$requestBody = "\r\n"
."\r\n"
."--myboundary\r\n"
."Content-Type: application/json\r\n"
."Content-Disposition: form-data\r\n"
."\r\n"
."$json_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";
// *** 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" )
);
And then I'm sending it off to get the recipient url for the Signing View: 然后我发送它以获取签名视图的收件人URL:
$data = array("returnUrl" => "http://quidfs.bfclients.com/dashboard",
"authenticationMethod" => "None",
"email" => 'something@gmail.com',
"userName" => 'Signer 1',
"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" )
);
Any thoughts? 有什么想法吗? Thanks in advance. 提前致谢。
I don't see you specifying a status in your request so I'm thinking that might be your issue. 我没有看到您在请求中指定状态,所以我认为这可能是您的问题。 If you do not specify the envelope status when you are creating it I believe the system saves the envelope as a Draft by default instead of sending it immediately. 如果您在创建信封时没有指定信封状态,我相信系统会默认将信封保存为草稿,而不是立即发送。
The two accepted status values are created
or sent
. created
或sent
两个接受的状态值。 Setting the status to created
in turn saves into your Drafts folder to be sent at a later time. 设置的状态created
依次保存到草稿文件夹在稍后的时间发送。 Setting the status to sent
sends the request immediately. 状态设置为sent
立即发送请求。
Try adding that into your request body, something like: 尝试将其添加到您的请求正文中,例如:
$data = array(
'status' => 'sent',
'accountId' => $accountId,
'documents' => array(
array(
'documentId' => '1',
'name' => 'document.pdf'
)
),
'recipients' => array(
'signers' => array( array(
array(
'tabs' => array(
'signHereTabs' => array(
array(
"pageNumber" => "1",
"documentId" => "1",
"yPosition" => "100",
"xPosition" => "100",
)
)
)
),
'routingOrder'=> '1',
'recipientId'=> '1',
'clientUserId'=> $clientUserId,
'name'=> 'Signer 1',
'email'=> 'something@gmail.com'
))
)
);
I got the same error 我得到了同样的错误
"errorCode": "RECIPIENT_NOT_IN_SEQUENCE", "message": "The token for an out of sequence recipient cannot be generated." “errorCode”:“RECIPIENT_NOT_IN_SEQUENCE”,“message”:“无法生成无序收件人的令牌。”
In my case, I have two recipients, both setting on 'routingOrder'=> '1'
cause my problem! 在我的情况下,我有两个收件人,都设置'routingOrder'=> '1'
导致我的问题! First, the signing was necessary to generate the second one token. 首先,签名是生成第二个令牌所必需的。 I changed on 'routingOrder'=> '0'
and solve my error. 我更改了'routingOrder'=> '0'
并解决了我的错误。
on my case i just set the envelopeDefinition status = "sent" before i call CreateRecipientView 在我的情况下,我只是在调用CreateRecipientView之前设置了envelopeDefinition status =“sent”
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.Status = "sent";
ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
Configuration cfi = new Configuration(apiClient);
string authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";
cfi.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
AuthenticationApi authApi = new AuthenticationApi(cfi);
LoginInformation loginInfo = authApi.Login();
string accountId = loginInfo.LoginAccounts[0].AccountId;
EnvelopesApi envelopesApi = new EnvelopesApi(cfi);
EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envDef);
// 3. Create Envelope Recipient View request obj
string envelopeId = results.EnvelopeId;
RecipientViewRequest viewOptions = new RecipientViewRequest
{
ReturnUrl = returnUrl,
ClientUserId = signerClientId,
AuthenticationMethod = "email",
UserName = signerName,
Email = signerEmail
};
// 4. Use the SDK to obtain a Recipient View URL
ViewUrl viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeId, viewOptions)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.