【问题标题】:Camel http GET call Status code 406骆驼 http GET 调用状态码 406
【发布时间】:2018-05-16 00:06:05
【问题描述】:

我正在尝试使用带有 Spring Boot 的 Camel 进行 GET 调用。当我使用以下代码时,我得到 406 代码。但是,如果我尝试使用邮递员到达端点,我会得到 200 响应(json)。请帮忙。

from(RouteUtils.buildSedaEndpointWithConcurrentConsumers("sedaEndpointin", domain.getThreads()))
                    .routeId("routeiD")
                    .setProperty("workerId").jsonpath("$.worker_id")
                    .setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.GET))
                    .setHeader(Exchange.HTTP_QUERY, simple(String.format("key=%s&barcode=${exchangeProperty.workerId}", apiKey)))
                    .setHeader(Exchange.HTTP_URI, simple("https://" + endpoint))
                    .setHeader("Authorization", simple(Auth))
                    .setHeader("Content-Type", constant("application/json"))
                    .to("http4://" + Endpoint)
                    .to("sedaEndpoint");

【问题讨论】:

    标签: rest get apache-camel http-status-code-406


    【解决方案1】:

    406 Not Acceptable 请求标识的资源仅 能够生成具有内容的响应实体 根据发送的接受标头,特征不可接受 请求。

    您发送的 application/json 似乎没有被客户端服务器接受,或者可能是同一端口上的两个不同项目。也检查一下。

    也试试这个... setHeader("Content-Type", constant("application/x-www-form-urlencoded")) 我猜。 阅读更多关于状态码错误Status Code 406

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 2019-12-15
      • 2013-02-10
      • 1970-01-01
      • 1970-01-01
      • 2015-09-07
      • 1970-01-01
      相关资源
      最近更新 更多