简体   繁体   English

Quarkus - 找不到内容类型应用程序/x-www-form-urlencoded 类型的作者

[英]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.

相关问题 javax.ws.rs.ProcessingException:找不到内容类型应用程序/x-www-form-urlencoded 类型的编写器 - javax.ws.rs.ProcessingException: could not find writer for content-type application/x-www-form-urlencoded type 如何编写控制器类以允许内容类型:application / json和application / x-www-form-urlencoded - How to write controller class to allow content-type: application/json and application/x-www-form-urlencoded 更改请求的内容类型以处理使用application / x-www-form-urlencoded发送的XML - Changing Content-Type of the request to process XML sent using application/x-www-form-urlencoded Spring MVC中内容类型应用程序/ x-www-form-urlencoded的请求参数的顺序 - Order of request parameters for content-type application/x-www-form-urlencoded in Spring MVC 用Java处理Content-Type =“ application / x-www-form-urlencoded”的SOAP请求 - Processing SOAP request with Content-Type = “application/x-www-form-urlencoded” in Java 在Spring Boot中使用内容类型application / x-www-form-urlencoded的请求的自定义反序列化器 - Custom deserializer for requests with content-type application/x-www-form-urlencoded in Spring Boot @JsonProperty 不适用于内容类型:application/x-www-form-urlencoded - @JsonProperty not working for Content-Type : application/x-www-form-urlencoded 如何使用“ Content-type:application / x-www-form-urlencoded”发出Okhttp请求? - How to make an Okhttp Request with “Content-type:application/x-www-form-urlencoded”? ContentCachingRequestWrapper 只捕获带有 Content-Type:application/x-www-form-urlencoded 的 POST 请求 - ContentCachingRequestWrapper only captures POST request with Content-Type:application/x-www-form-urlencoded 当内容类型为 application/x-www-form-urlencoded 时,Java 读取 POST 数据 - Java read POST data when content-type is application/x-www-form-urlencoded
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM