Sparkler-blush
Sparkler-blush

Reputation: 37

Camel http GET call Status code 406

I am trying to make a GET call using Camel with Spring Boot. When I use the following code, I get 406 code. But if I try hitting the endpoint using postman I get 200 with response (json). Please help.

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");

Upvotes: 0

Views: 907

Answers (1)

Lucifer
Lucifer

Reputation: 832

406 Not Acceptable The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

It seems that application/json you are sending is not accepting by client server or might be two different projects on the same port. Check that too.

Try this too... setHeader("Content-Type", constant("application/x-www-form-urlencoded")) my guess. Read more about status code error Status Code 406

Upvotes: 1

Related Questions