我正在尝试将Docusign集成到我们的Java(Java-11(应用程序中。
我正试图使用JWT流程来实现同样的目的。在授权该应用程序后,我可以创建访问令牌,但当尝试创建信封和创建嵌入请求时,我看到以下错误:
[2021-07-21 15:00:32.954] [EC2AMAZ-5EFUJD8] [http-nio-8080-exec-2] ERROR c.p.e.h.GovCloudBaseExceptionHandler@handleException:237 - -- handleException() - {}
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=text/html;charset=utf-8, type=class com.docusign.esign.model.EnvelopeSummary, genericType=class com.docusign.esign.model.EnvelopeSummary.
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:232)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:156)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1091)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:874)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:834)
at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:363)
at org.glassfish.jersey.client.InboundJaxrsResponse$2.call(InboundJaxrsResponse.java:126)
at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
at org.glassfish.jersey.internal.Errors.process(Errors.java:229)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestSco
下面代码中的createEnvelope方法抛出错误
void CreateEnvelope()
{
// Create the envelope definition
EnvelopeDefinition envelope = null;
try {
envelope = makeEnvelope("anur.puniyani@teliolabs.com", "Anur");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Call DocuSign to create the envelope
//ApiClient apiClient = createApiClient("", bearerToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeSummary envelopeSummary = null ;
try {
envelopeSummary = envelopesApi.createEnvelope("1a9c289e-f63d-4f63-b6cd-5c43af184603", envelope);
} catch (ApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
envelopeId = envelopeSummary.getEnvelopeId();
System.out.println("Envelope ID (&(*&(&( !!!!= "+envelopeId);
}
我为ApiClient构造函数使用了以下基本url:https://account-d.docusign.com因为我的应用程序面板(demo.docusign.com(中的那个似乎不适用于授予权限,并且抛出了一个未找到的页面错误。
请帮我和我的同事一整天都在处理这个问题。我们尝试联系支持部门,但除非您拥有许可证,否则他们不会提供API支持。
/restapi
,应该是https://demo.docusign.com/restapi
。此外,我错误地说docusign.net应该是docusign.com
据我所知,没有类方法可以直接在EnvelopeDefinition中创建信封。您需要指定API调用成功所需的各种关联部分。这部分代码来自我们Launcher中的eSignature示例002。我做了一些小的更改,使其能够与单个文档一起使用。您需要将此信封定义发送到主机";demo.docusign.net":
package com.docusign.controller.eSignature.examples;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import com.docusign.esign.api.EnvelopesApi;
import com.docusign.esign.client.ApiClient;
import com.docusign.esign.client.ApiException;
import com.docusign.esign.model.Document;
import com.docusign.esign.model.EnvelopeDefinition;
import com.docusign.esign.model.EnvelopeSummary;
import com.docusign.esign.model.Recipients;
import com.docusign.esign.model.SignHere;
import com.docusign.esign.model.Signer;
import com.docusign.esign.model.Tabs;
class CreateEnvelope
{
public static void main(String[] args) {
// Create the envelope definition
String accessToken = "eyJ0eXAi......JgAkJuZ8A";
String accountId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx";
// Call DocuSign to create the envelope
ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
apiClient.addDefaultHeader("Authorization", "Bearer " + accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeDefinition envelope = makeEnvelope("anur.puniyani@teliolabs.com", "Anur");
try {
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envelope);
String envelopeId = envelopeSummary.getEnvelopeId();
System.out.println("Envelope ID = "+envelopeId);
} catch (ApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static EnvelopeDefinition makeEnvelope(String signerEmail, String signerName) {
// Create a signer recipient to sign the document, identified by name and email
// We set the clientUserId to enable embedded signing for the recipient
Signer signer = new Signer();
signer.setEmail(signerEmail);
signer.setName(signerName);
// signer.clientUserId("1000"); # will not receive docuSign email to sign if client user id is present
signer.recipientId("1");
SignHere signHere = new SignHere();
signHere.setAnchorString("/sn1/");
signHere.setAnchorUnits("pixels");
signHere.setAnchorYOffset("20");
signHere.setAnchorXOffset("10");
Tabs signerTabs = new Tabs();
signerTabs.setSignHereTabs(Arrays.asList(signHere));
// Add the recipient to the envelope object
Recipients recipients = new Recipients();
recipients.setSigners(Arrays.asList(signer));
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
envelopeDefinition.setEmailSubject("Please sign this document");
envelopeDefinition.setRecipients(recipients);
Path path = Paths.get("./path/to/my/code-examples-java/src/main/resources/World_Wide_Corp_lorem.pdf");
byte[] data = null;
try {
data = Files.readAllBytes(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Document document = new Document();
document.setDocumentBase64(Base64.getEncoder().encodeToString(data));
document.setName("Hello Doc");
document.setFileExtension("pdf");
document.setDocumentId("3");
envelopeDefinition.setDocuments(Arrays.asList(document));
// Request that the envelope be sent by setting |status| to "sent".
// To request that the envelope be created as a draft, set to "created"
envelopeDefinition.setStatus("sent");
return envelopeDefinition;
}
}
上面的代码来自这里的代码示例启动器。还提供了一个预打包版本,在Quickstart页面的此处填写了您的所有配置详细信息。