'Quarkus - could not find writer for content-type application/x-www-form-urlencoded type
This is my code for doing a request with jax-rs Client:
private Client client;
private static final int TIMEOUT = 8000;
@PostConstruct
public void init() {
client = ClientBuilder.newBuilder()
.readTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.build();
}
....
final String resource = "/some-endpoint/{id}/securityinfo";
final String path = url + resource;
final WebTarget target = client
.target(path)
.resolveTemplate("id", email);
final var form = new Form().param("mail", email);
final Response response = target
.request()
.post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED));
if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
throw new MyException(response.readEntity(String.class));
}
I receive the error:
javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request: javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/x-www-form-urlencoded type: javax.ws.rs.core.Form
This happens only with form - content type request, as the json support works properly.
EDIT
These are the dependencies used:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-oracle</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
Solution 1:[1]
Have you tried using (https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/Entity.html#form-javax.ws.rs.core.Form-) :
Entity.form(form);
I'm not sure it will fix the issue as it is just shorthand for what you have. But i would give it a try.
In order to find a solution easier can you share the dependencies you are using on your project.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Diogo Sarmento |
