我在Java中为DocuSign使用REST API。我试图用文档嵌入签名(最终到我的页面中的iframe),而不是像API演练中的模板。仔细看看这里,我发现这可以通过合并来自embeddedSigning和requestSigning API演练的代码来完成,但我很难做到这一点。现在我认为我很接近,但却陷入了一个错误,我不知道它在说什么。用Docusign中的文档进行嵌入式签名
//============================================================================
//STEP 2 - Signature Request on Document API Call
//============================================================================
url = baseURL + "/envelopes"; // append "/envelopes" to baseUrl for signature request call
//this example uses XML formatted requests, JSON format is also accepted
//following body will place one signature tab 100 pixels right and 100 down from top left corner of document
body = "<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
"<status>sent</status>" +
"<emailSubject>API Call for adding signature request to document and sending</emailSubject>" +
//add document(s)
"<documents>" +
"<document>" +
"<documentId>1</documentId>" +
"<name>" + documentName + "</name>" +
"</document>" +
"</documents>" +
//add recipient(s)
"<recipients>" +
"<signers>" +
"<signer>" +
"<recipientId>1</recipientId>" +
"<name>" + recipientName + "</name>" +
"<email>" + recipientEmail + "</email>" +
"<clientUserId>1001</clientUserId>" +
"<tabs>" +
"<signHereTabs>" +
"<signHere>" +
"<xPosition>100</xPosition>" +
"<yPosition>100</yPosition>" +
"<documentId>1</documentId>" +
"<pageNumber>1</pageNumber>" +
"</signHere>" +
"</signHereTabs>" +
"</tabs>" +
"</signer>" +
"</signers>" +
"</recipients>" +
"</envelopeDefinition>";
// re-use connection object for second request...
conn = InitializeRequest(url, "POST", body, authenticationHeader);
// read document content into byte array
File file = new File("./" + documentName);
InputStream inputStream = new FileInputStream(file);
byte[] bytes = new byte[(int) file.length()];
inputStream.read(bytes);
inputStream.close();
// start constructing the multipart/form-data request...
String requestBody = "\r\n\r\n--BOUNDARY\r\n" +
"Content-Type: application/xml\r\n" +
"Content-Disposition: form-data\r\n" +
"\r\n" +
body + "\r\n\r\n--BOUNDARY\r\n" + // our xml formatted request body
"Content-Type: " + docContentType + "\r\n" +
"Content-Disposition: file; filename=\"" + documentName + "\"; 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";
// 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();
System.out.println("STEP 2: Creating envelope from document...\n");
status = conn.getResponseCode(); // triggers the request
if(status != 201) // 201 = Created
{
errorParse(conn, status);
return;
}
// obtain envelope uri from response body
response = getResponseBody(conn);
String uri = parseXMLBody(response, "uri");
System.out.println("-- Envelope Creation response --\n\n" + prettyFormat(response, 2));
//============================================================================
//STEP 3 - Get the Embedded Signing View
//============================================================================
url = baseURL + uri + "/views/recipient"; // append envelope uri + "views/recipient" to url
//this example uses XML formatted requests, JSON format is also accepted
body = "<recipientViewRequest xmlns=\"http://www.docusign.com/restapi\">" +
"<authenticationMethod>email</authenticationMethod>" +
"<email>" + recipientEmail + "</email>" +
"<returnUrl>http://www.docusign.com/devcenter</returnUrl>" +
"<clientUserId>1001</clientUserId>" + //*** must match clientUserId set in Step 2!
"<userName>" + recipientName + "</userName>" +
"</recipientViewRequest>";
System.out.print("Step 3: Generating URL token for embedded signing... ");
conn = InitializeRequest(url, "POST", body, authenticationHeader);
status = conn.getResponseCode(); // triggers the request
if(status != 201) // 201 = Created
{
errorParse(conn, status);
return;
}
System.out.println("done.");
response = getResponseBody(conn);
String urlToken = parseXMLBody(response, "url");
System.out.println("\nEmbedded signing token created:\n\t" + urlToken);
而且我得到这个错误:
第3步:生成URL令牌嵌入式签署... API调用失败,返回状态为:411 [致命错误]:1:50:白色空间是publicId和systemId之间需要。
我对这一切都很陌生,所以任何与我应该如何嵌入签名文件的帮助将不胜感激。 错误:'publicId和systemId之间需要空格。'
我从来没有见过这个错误,你能发表什么传递(一个跟踪)和一个完整的错误。听起来不像是来自DocuSign – Andrew