Search code examples
quarkus-rest-clientquarkus-reactive

Quarkus-REST jackson client sends empty payload to POST requests


I'm trying to migrate to quarkus-rest v3.13.2. client from quarkus-resteasy. However with the latest quarkus version my REST client sends only GET params and completely ignores POST body. I'm running the test in JVM (non-native) DEV mode locally. I guess I should include an additional library or other simple stuff. However cannot identify how to resolve it so far. Thank you in advance.

My code:

// Rest client generated by swagger (with manyally added annotations)

@Path("/api/v/2024-03-20")
public interface ResourceClient {
    @POST
    @Path("resource")
    CreateResourceResponse createResource(CreateResource body);
}

// DTO generated by swagger

@ApiModel(description = "The `createResource` request.")
@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2024-06-12T12:45:38.427+02:00")
@RegisterForReflection
public class CreateResourceRequest {
  @JsonProperty("dataList")
  private List<String> dataList = new ArrayList<>();

  @JsonProperty("items")
  private List<ItemInput> items = new ArrayList<>();
}

Client initialization

@Provides
public ResourceClient getClient(/.../) {
        return QuarkusRestClientBuilder.newBuilder()
                .baseUri(URI.create(uri))
                .queryParamStyle(QueryParamStyle.COMMA_SEPARATED)
                .register(ExceptionMapper.class)
                .build(ResourceClient.class);
}

pom.xml

       <!-- REST clients generation -->
        <dependency>
            <!--
              * If your application uses a client and exposes REST endpoints,
                please use Quarkus REST for the server part.
              * Please note that the quarkus-resteasy-client extension may not be used with Quarkus REST,
                use quarkus-rest-client instead.

              See https://quarkus.io/guides/rest-client
             -->
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest-client</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest-client-jackson</artifactId>
        </dependency>
        <dependency>
            <!-- Generates rest API handler lambda (YES I USE REST SERVER AND CLIENT IN THE SAME SUB-MODULE -->
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-amazon-lambda-rest</artifactId>
        </dependency>

I enabled logs in my application-dev.properties

quarkus.rest-client.logging.scope=request-response
quarkus.rest-client.logging.body-limit=1024
quarkus.log.category."org.jboss.resteasy.reactive.client.logging".level=DEBUG

And can see that the payload is empty. However I'm sure I pass correct non null fields.

(vert.x-eventloop-thread-0) Request: POST https://. .... content-length=0], Empty body

P.S. I've reported an issue to Quarkus here (basically same question): https://github.com/quarkusio/quarkus-quickstarts/issues/1440#issue-2462892445


Solution

  • The issue was due to an interceptor that was reading rendering stream. Implementations of resteasy and cuarkus-rest writers are different and it causes issues.

    See this comment for explanation. If you face similar issue, you can apply a simple fix