typesense / typesense-java

Java client for Typesense
https://typesense.org/docs/latest/api/
Apache License 2.0
58 stars 28 forks source link

Uploading a document is resulting in a NoSuchMethodError for okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType) #53

Closed ragdhall closed 8 months ago

ragdhall commented 9 months ago

Description

I'm attempting to create a document in my collection using typesenseClient.collections("collection-name").documents().create(document);

However, I'm getting the following error message Internal Server Error - Error id 142e7db4-8c21-450f-acc1-288b15d368a2-2, org.jboss.resteasy.spi.UnhandledException: java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'

When I try and directly hit the create endpoint with postman it successfully creates a document.

Steps to reproduce

I initialized the client using

        List<Node> nodes = new ArrayList<>();
        nodes.add(
                new Node(
                        "https",
                        "<typesense-cloud>",
                        "443"
                )
        );
        String apiKey = "***"
        Configuration configuration = new Configuration(nodes, Duration.ofSeconds(2),apiKey);
        typesenseClient = new Client(configuration);

I'm able to do a retrieve using this client.

Then, I try to upload a document using

        ImportDocumentsParameters importDocumentsParameters = new ImportDocumentsParameters();
        importDocumentsParameters.dirtyValues(ImportDocumentsParameters.DirtyValuesEnum.COERCE_OR_DROP);
        importDocumentsParameters.action("create");

        typesenseClient.collections("collection-name").documents().create(document);

Expected Behavior

Document is successfully created in my collection.

Actual Behavior

I get the following error message

Internal Server Error - Error id 565e6fa7-220e-4afa-8f62-ae1890d1bf5d-1,
        org.jboss.resteasy.spi.UnhandledException: java.lang.NoSuchMethodError: 'okhttp3.RequestBody
        okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'

Metadata

Typesense Version: 0.5.0

OS: Windows 11

ragdhall commented 8 months ago

I realized I was getting this error because of a conflicting okhttp dependency version in quarkus platform.