将信封移动到回收站时的ClientHandlerException

时间:2017-04-04 13:03:52

标签: java rest docusignapi

我目前正在尝试将信封移至回收站以便将其删除。

这是我的代码:

public class DeleteEnvelopeTest {
    public static final String BaseUrl = "https://demo.docusign.net/restapi";

    @Test
    public void shouldDeleteTheEnvelopeTest() {
        try {
            FoldersApi foldersApi = new FoldersApi();
            String envelopeId = "envelopeId";
            FoldersRequest foldersRequest = new FoldersRequest();
            foldersRequest.setEnvelopeIds(Arrays.asList(envelopeId));
            System.out.println(foldersApi.moveEnvelopes(accountId, "recyclebin", foldersRequest));
        } catch (ApiException ex) {
            System.out.println("Exception: " + ex);
        }
    }
}

执行此代码时,我有以下异常:

    GRAVE: The registered message body readers compatible with the MIME media type are:
    */* ->
      com.sun.jersey.core.impl.provider.entity.FormProvider
      com.sun.jersey.core.impl.provider.entity.StringProvider
      com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
      com.sun.jersey.core.impl.provider.entity.FileProvider
      com.sun.jersey.core.impl.provider.entity.InputStreamProvider
      com.sun.jersey.core.impl.provider.entity.DataSourceProvider
      com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
      com.sun.jersey.core.impl.provider.entity.ReaderProvider
      com.sun.jersey.core.impl.provider.entity.DocumentProvider
      com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
      com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
      com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
      com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
      com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
      com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
      com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
      com.sun.jersey.core.impl.provider.entity.EntityHolderReader
    application/octet-stream ->
      com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
      com.sun.jersey.core.impl.provider.entity.FileProvider
      com.sun.jersey.core.impl.provider.entity.InputStreamProvider
      com.sun.jersey.core.impl.provider.entity.DataSourceProvider
      com.sun.jersey.core.impl.provider.entity.RenderedImageProvider


    com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class com.docusign.esign.model.FoldersResponse, and Java type class com.docusign.esign.model.FoldersResponse, and MIME media type application/octet-stream was not found

        at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:630)
        at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:604)
        at com.docusign.esign.client.ApiClient.invokeAPI(ApiClient.java:606)
        at com.docusign.esign.api.FoldersApi.moveEnvelopes(FoldersApi.java:206)
        at com.orange.digisign.DeleteEnvelopeStatusTest.shouldDeleteTheEnvelopeTest(DeleteEnvelopeStatusTest.java:71)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
        at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
        at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
        at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)


Process finished with exit code 255

这里奇怪的是,当我进入我的DocuSign帐户时,我清楚地看到要删除到回收站的信封。 Si,从这个角度来看,测试似乎有效。但我总是有这个错误。你知道它可以来自哪里吗?

我不确定这是地雷的错误。验证过程似乎是正确的,因为信封被移动,因为它与创建和更新信封的过程相同。

DocuSign有可能返回格式错误的JSON吗?或者说FoldersApi的返回类型与EnvelopesApi不同(这是我第一次使用FoldersApi)?我在文档中没有看到任何关于它的内容,但我可能错过了它。

谢谢,

编辑: 在我的日志中,我发现了这个:

PUT https://demo.docusign.net:7801/restapi/v2/accounts/2092727/folders/recyclebin

TraceToken: 48870a20-f9a8-445f-93ff-149c0d6e2c12
Timestamp: 2017-04-04T14:22:33.4101035Z

Content-Length: 56
Content-Type: application/json
Connection: keep-alive
Accept: application/json
Host: demo.docusign.net
User-Agent: Swagger-Codegen/2.0.2/java
X-DocuSign-Authentication: {"Password":"[omitted]","Username":"myEmail","IntegratorKey":"[omitted]"}
X-DocuSign-SDK: Java
X-SecurityProtocol-Version: TLSv1.2
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-GCM-SHA384
x-forwarded-for: 194.51.78.65

{"envelopeIds":["myEnvelopeId"]}
200 OK
X-DocuSign-TraceToken: 48870a20-f9a8-445f-93ff-149c0d6e2c12

你还需要其他什么吗?

编辑2: 经过更多调查,我发现了以下结果:

在DocuSign的ApiClient.java类中,异常是抛出方法invokeAPI,更准确地说是第606行。这是相应代码部分的部分:

public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {

    ClientResponse response = getAPIResponse(path, method, queryParams, body, headerParams, formParams, accept, contentType, authNames);

    statusCode = response.getStatusInfo().getStatusCode();
    responseHeaders = response.getHeaders();

     if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
      if (returnType == null)
        return null;
      else
        return response.getEntity(returnType);
    } 
}

抛出异常的方法是“getEntity”,即使我将“class com.docusign.esign.mlodel.FoldersResponse”视为“returnType”的字段。

任何帮助?

编辑3:我想,我找到了解决方案,或者至少是解释。通过执行一些其他测试。 我现在获得以下消息:

com.docusign.esign.client.ApiException: missing Content-Type in response

所以,我猜,问题出在DocuSign本身......你同意吗?

0 个答案:

没有答案