Встроенная подпись api docusign

Я использую DocuSign для добавления электронной подписи к моим запросам, и все работает хорошо. Прямо сейчас я отправляю свои запросы на подпись, используя встроенный метод - для немедленного запуска моих рабочих процессов путем перехода к URL-адресу.

После входа в систему и выполнения приведенного ниже кода я получаю (встроенное представление: https://demo.docusign.net/Member/StartInSession.aspx?StartConsole=1&t=32598057-5a59-4d0b-bad8-a8ff8f2407f6&DocuEnvelope=168bc155-e013-4ffd-abb4-7608b56647f8&send=1), но когда я вставлю URL-адрес, чтобы попытаться подписать документ в навигационной системе, но перенаправлю меня на другой URL-адрес ( http://www.docusign.com/?event=Send&envelopeId=168bc155-e013-4ffd-abb4-7608b56647f8),

Как я могу запустить процесс wotkflow, чтобы подписать конверт?? я не вижу свою конверт, чтобы подписать его.

// ШАГ 2 - Создать конверт с одним получателем, документом и вкладкой и отправить //

    String jsonBody = "{\"emailBlurb\":\"partail\"," + 
            "\"emailSubject\":\"API Call for adding signature request to document and sending\"," + 
            "\"documents\":[{" + 
            "\"documentId\":\"1\"," + 
            "\"name\":\"test.pdf\"}]," + 
            "\"recipients\":{" + 
            "\"signers\":[{" + 
            "\"email\":\"" + EmailRecipients + "\"," + 
            "\"name\":\"name\"," + 
            "\"recipientId\":\"1\"," +
            "\"routingOrder\":\"1\","+
            "\"clientUserId\":\"1000\","+              
            "\"tabs\":{" + 
            "\"signHereTabs\":[{" + 
            "\"xPosition\":\"300\"," + 
            "\"yPosition\":\"600\"," + 
            "\"documentId\":\"1\"," + 
            "\"pageNumber\":\"1\"" + "}]}}]}," + 
            "\"status\":\"sent\"}";
          //DemandeSign.getenvelope();


    File file = new File("D:/test.pdf");
    InputStream inputStream = new FileInputStream(file); 
    byte[] bytes = new byte[(int) file.length()];
    inputStream.read(bytes);
    inputStream.close();

    String requestBody = "\r\n\r\n--BOUNDARY\r\n" + 
            "Content-Type: application/json\r\n" + 
            "Content-Disposition: form-data\r\n" + 
            "\r\n" + 
            jsonBody + "\r\n\r\n--BOUNDARY\r\n" +   // our json formatted request body
            "Content-Type: application/pdf\r\n" + 
            "Content-Disposition: file; filename=\"test.pdf\"; documentId=1\r\n" + 
            "\r\n";
        // we break this up into two string since the PDF doc bytes go here and are not in string format.
        // see further below where we write to the outputstream...
    String reqBody2 = "\r\n" + "--BOUNDARY--\r\n\r\n";

    // append "/envelopes" to the baseUrl and use in the request
    conn = (HttpURLConnection)new URL(baseURL + "/envelopes").openConnection();
    conn.setRequestMethod("POST");
    conn.setDoOutput(true);
    conn.setRequestProperty("X-DocuSign-Authentication", authenticateStr);
    conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=BOUNDARY");
    conn.setRequestProperty("Content-Length", Integer.toString(requestBody.toString().length()));
    conn.setRequestProperty("Accept", "application/xml"); 

    // write the body of the request...
    DataOutputStream dos = new DataOutputStream( conn.getOutputStream() );
    dos.writeBytes(requestBody.toString()); 
    dos.write(bytes);
    dos.writeBytes(reqBody2.toString()); 
    dos.flush(); dos.close();
    status = conn.getResponseCode(); // triggers the request
    if( status != 201 ) // 201 = Created
    {
        System.out.println("Error calling webservice, status is: " + status);
        InputStreamReader isr = new InputStreamReader( conn.getErrorStream() );
        br = new BufferedReader(isr);
        StringBuilder error_response = new StringBuilder();
        while ( (line = br.readLine()) != null)
            error_response.append(line);
        System.out.println("Error response is " + error_response.toString() );
        System.exit(-1);
    }
    // Read the response
    InputStreamReader isr = new InputStreamReader( conn.getInputStream() );
    br = new BufferedReader(isr);
    StringBuilder response2 = new StringBuilder();
    while ( (line = br.readLine()) != null)
        response2.append(line);
    //token1 = "//*[1]/*[local-name()='envelopeId']";
    //String envelopeId = xPath.evaluate(token1, new InputSource(new StringReader(response2.toString())));

    //--- display results
    //System.out.println("Document sent!  envelopeId is " + envelopeId );//envelopeId is e4c0659a-9d01-4ac3-a45f-02a80fd6bd96 at 04/07/2013 17:24


    token1 = "//*[1]/*[local-name()='uri']";
    String uri = xPath.evaluate(token1, new InputSource(new StringReader(response2.toString())));
    //--- display results
    System.out.println("uri = " + uri );


/// Step3
// construct another outgoing XML request body
String reqBody = "<returnUrlRequest xmlns=\"http://www.docusign.com/restapi\">" +
"<authenticationMethod>email</authenticationMethod>" +
"<email>***test@gmail.com***</email>" +
"<returnUrl>http://www.docusign.com</returnUrl>" +
"<userName>name</userName>" +
"<clientUserId>1000</clientUserId>" +
"</returnUrlRequest>";

// append uri + "/views/sender" to the baseUrl and use in the request
conn = (HttpURLConnection)new URL(baseURL + uri + "/views/sender").openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("X-DocuSign-Authentication", authenticateStr);
conn.setRequestProperty("Content-Type", "application/xml");
conn.setRequestProperty("Content-Length", Integer.toString(reqBody.length()));
conn.setRequestProperty("Accept", "application/xml");
// write the body of the request...
dos = new DataOutputStream( conn.getOutputStream() );
dos.writeBytes(reqBody); dos.flush(); dos.close();
status = conn.getResponseCode(); // triggers the request
if( status != 201 ) // 201 = Created
{
System.out.println("Error calling webservice, status is: " + status);
System.exit(-1);
}
// Read the response
isr = new InputStreamReader( conn.getInputStream() );
br = new BufferedReader(isr);
StringBuilder response3 = new StringBuilder();
while ( (line = br.readLine()) != null)
response3.append(line);
token1 = "//*[1]/*[local-name()='url']";
//--- display results
System.out.println("Embedded View: " + xPath.evaluate(token1, new InputSource(new StringReader(response3.toString()))));`

1 ответ

Вы пытаетесь получить доступ к URL немедленно или вообще ждете? После того, как вы сгенерируете токен URL для доступа к данному конверту, у него будет TTL (время жизни) 5 минут, то есть срок его действия истекает через 5 минут, а затем вам нужно сгенерировать новый.

Если это не так, ваша проблема может быть связана с тем, как вы идентифицируете своего получателя. Получатель в DocuSign идентифицируется по уникальной комбинации их имени, адреса электронной почты, receientId и, в случае встраивания, clientUserId. Кажется, вы настраиваете все эти параметры, однако, независимо от того, какая комбинация существует при первом создании конверта, вам необходимо обращаться к той же комбинации, когда вы запрашиваете встроенный URL-токен.

Когда вы создаете свой конверт, я вижу, что вы устанавливаете имя буквально на "имя" и что вы устанавливаете адрес электронной почты через переменную с именем "EmailRecipients". Но когда вы запрашиваете URL-токен, вы используете адрес электронной почты "test@gmail.com", это может быть причиной вашей проблемы.

Другие вопросы по тегам