Embed signature api docusign

I use DocuSign to add eSignature to my queries and everything works fine. Right now I am sending my signature requests using the Embedded method to immediately initiate my workflows by going to the URL.

After logging in and executing the following code, I get (Embedded View: https://demo.docusign.net/Member/StartInSession.aspx?StartConsole=1&t=32598057-5a59-4d0b-bad8-a8ff8f2407f6&DocuEnvelope=168bc155-e013-4ffd abb4-7608b56647f8 & send = 1 ), but when I paste the URL into try to sign the document in the navigation, but redirect me to another URL ( http://www.docusign.com/?event=Send&envelopeId=168bc155-e013-4ffd -abb4-7608b56647f8 ),

how can'i start the wotkflow process to sign my envelope ?? I do not see my envelope sign it.

// STEP 2 - Create an envelope with one recipient, document and tab and send //

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()))));` 
0
source share
1 answer

Are you trying to access the url immediately or not at all? When you create a URL token to access this envelope, it has a TTL (lifetime) of 5 minutes, that is, it expires in 5 minutes, and then you need to create a new one.

If this is not the case, your problem may be related to how you identify your recipient. The recipient in DocuSign is identified by a unique combination of their name, email, recipientId, and if implemented, clientUserId. It seems that you are setting all these parameters, however no matter what combination the first time you create an envelope, you need to refer to the same combination when you ask for the embedded URL token.

When you create your envelope, I see that you literally set the name to “name” and you set up email using the “EmailRecipients” variable. But when you request the token of the URL, you use the email " test@gmail.com ", which may cause your problem.

0
source

All Articles