Docusignapi Docusign API-嵌入式签名出现问题

Docusignapi Docusign API-嵌入式签名出现问题,docusignapi,Docusignapi,我正在尝试在我正在构建的网站上为用户使用工作流中的嵌入式签名。我经常(通过API资源管理器和我自己的代码)得到的错误是: “错误代码”:“收件人不在顺序中”, “消息”:“无法生成顺序错误收件人的令牌。” 首先,我上传文档以创建一个信封并附上一个收件人: $data = array( 'accountId' => $accountId, 'documents' => array( array(

我正在尝试在我正在构建的网站上为用户使用工作流中的嵌入式签名。我经常(通过API资源管理器和我自己的代码)得到的错误是:

“错误代码”:“收件人不在顺序中”, “消息”:“无法生成顺序错误收件人的令牌。”

首先,我上传文档以创建一个信封并附上一个收件人:

   $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" )                                                                       
    );
然后我发送它以获取签名视图的收件人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" )                                                                       
        );

有什么想法吗?提前感谢。

我没有看到您在请求中指定状态,因此我认为这可能是您的问题。如果在创建信封时未指定信封状态,我相信系统会默认将信封保存为草稿,而不是立即发送

两个接受的状态值是
已创建
已发送
。将状态设置为
created
会依次保存到草稿文件夹中,以便稍后发送。将状态设置为“已发送”会立即发送请求

尝试将其添加到您的请求正文中,例如:

$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'
            ))
        )
    );
我也犯了同样的错误

“错误代码”:“收件人不在顺序中”,“消息”:“无法生成顺序错误收件人的令牌。”

在我的例子中,我有两个收件人,都设置为
'routingOrder'=>1'
导致我的问题! 首先,签名是生成第二个令牌所必需的。
我更改了
'routingOrder'=>'0'
并解决了我的错误。

在我的案例中,我只需在调用CreateRecipientView之前设置信封定义状态=“已发送”

        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)

请发布
accounts/{accountId}/envelopes/{envelopeId}/recipients
的结果,这样我们就可以看到
$clientUserId
是一个实际传递的值。(添加状态=>发送成功)谢谢!