[英]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:这是我使用 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
javax.ws.rs.ProcessingException:RESTEASY004655:无法调用请求:javax.ws.rs.ProcessingException:RESTEASY003215:找不到内容类型应用程序/x-www-form-urlencoded 类型的编写器:javax.ws.rs。核心.形式
This happens only with form - content type request, as the json support works properly.这仅发生在表单 - 内容类型请求中,因为 json 支持正常工作。
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>
Have you tried using ( https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/Entity.html#form-javax.ws.rs.core.Form- ):您是否尝试过使用( 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.为了更容易地找到解决方案,您可以共享您在项目中使用的依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.