onshape-public / java-client

MIT License
3 stars 4 forks source link

Receiving error: RESTEASY003145: Unable to find a MessageBodyReader #33

Open b-m-r opened 2 years ago

b-m-r commented 2 years ago

I created a API key and set it as variable in the IDE. If I now try the to access anything with the Onshape Client I receive following Error:

Exception in thread "main" javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/vnd.onshape.v1+json;charset=UTF-8 and type class java.io.InputStream
    at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(ClientReaderInterceptorContext.java:37)
    at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:80)
    at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
    at com.onshape.api.base.CompressionReaderInterceptor.aroundReadFrom(CompressionReaderInterceptor.java:47)
    at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:59)
    at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:211)
    at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:89)
    at org.jboss.resteasy.specimpl.AbstractBuiltResponse.readEntity(AbstractBuiltResponse.java:262)
    at com.onshape.api.base.BaseClient.call(BaseClient.java:426)
    at com.onshape.api.requests.DocumentsGetDocumentsRequest$Builder.call(DocumentsGetDocumentsRequest.java:342)
    at ch.bmr.onshape.DocumentTests.main(DocumentTests.java:36)

What am I doing wrong:

public class DocumentTests {
  private static Onshape CLIENT;

  public static void main(String[] args) throws OnshapeException {

    CLIENT = new Onshape();

    String accessKey = System.getenv("ONSHAPE_API_ACCESSKEY");
    String secretKey = System.getenv("ONSHAPE_API_SECRETKEY");
    if ((accessKey == null || accessKey.isEmpty()) || (secretKey == null || secretKey.isEmpty())) {
      throw new OnshapeException("Please define ONSHAPE_API_ACCESSKEY and ONSHAPE_API_SECRETKEY environment variables");
    }
    CLIENT.setAPICredentials(accessKey, secretKey);
    CLIENT.setBaseURL("https://xxx.onshape.com");

    DocumentsGetDocumentsResponse call = CLIENT.documents()
                                               .getDocuments()
                                               .call();
    System.out.println("call = " + call);

  }
}

If I change the variable, I receive an unauthorized exception. Does anybody can help me or write a quick guide how to connection with oauth or api key works? Thanks

harmanpa commented 2 years ago

I've seen a similar error when running with Java 11, the library was developed and tested with Java 8, so I believe it is a change in dependencies, I will investigate further.

b-m-r commented 2 years ago

you are right! With Java 8 it works! Unfortunately I have to have it for java 11. Can you have a look on the dependencies?

harmanpa commented 2 years ago

Thanks for testing and confirming. I'll try and locate the missing dependency.

b-m-r commented 2 years ago

I downloaded and compiled the code for Java 11 and it works. So I'm not really sure why it doesn't work if I include it with maven.