Hi,
I am also getting the same error that <API URL> returned a response status
of 411 Length Required.
I want to read header passed in POSTMAN in code . Please help me how to
fetch Header send in POSTMAN using java REST API.
On Monday, February 18, 2013 at 6:48:41 AM UTC+5:30, Felix Gao wrote:
>
> Hi, I am using dropwizard version 0.6.1
> Jersey client is created as
> final JerseyClientBuilder builder = new JerseyClientBuilder()
> .using(configuration.getJerseyClientConfiguration())
> .using(environment);
> final Client jerseyClient = builder.build();
> with the following properties
> #http Client property for jersey
> httpClient:
> # timeout after 3s while connecting, reading, or writing
> timeout: 3s
> # keep connections open for 10 minutes
> timeToLive: 10m
> # don't track cookies
> cookiesEnabled: false
> # gzipEnabled: true # allow for gzipped request and response entities
> # If true, the client will encode request entities with gzip
> # content encoding. (Requires gzipEnabled to be true).
> # gzipEnabledForRequests: true
> minThreads: 1
> maxThreads: 128 # thread pool for JerseyClient's async requests
>
>
> this is code snipped that I ran to get the error
>
> @Override
> public void run() {
> for(Location l : this.locations){ //Location is just a simple
> pojo
> String cr = null;
> try {
> final String s = mapper.writeValueAsString(l);
> cr = this.resource
> .type(MediaType.APPLICATION_JSON_TYPE)
> .accept(MediaType.APPLICATION_JSON_TYPE)
> .post(String.class, s);
> } catch (JsonProcessingException e) {
> logger.error("JSON process error for "+l, e);
> }
> }
> }
>
> this is what I got back from the server
> 2 * Client out-bound request
> 2 > POST http://api.testhost.com/location
> 2 > Content-Type: application/json
> 2 > Accept: application/json
> � �ێ�0 E ��� "_0 ޘD��� �L3����68!0 '-�����y��^��wP��C�4� rg D� � ��� P*
> B�9�� �!� D� S
> �k�W7� [ʶ�6
> ���GF���3V�� �5�j ւ >}�A� �rf��1Dā�A� �!�B����? lP"�
> Exception in thread "pool-4-thread-1"
> com.sun.jersey.api.client.UniformInterfaceException: Client response
> status: 411
> at com.sun.jersey.api.client.WebResource.handle(WebResource.java:686)
> at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
> at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568)
> at
> com.katami.concurrent.thread.LocationRestInsertion.run(LocationRestInsertion.java:58)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:680)
> 2 * Client in-bound response
> 2 < 411
> 2 < Server: nginx/0.7.65
> 2 < Date: Mon, 18 Feb 2013 01:14:30 GMT
> 2 < Content-Type: text/html
> 2 < Content-Length: 181
> 2 < Connection: close
> 2 <
> <html>
> <head><title>411 Length Required</title></head>
> <body bgcolor="white">
> <center><h1>411 Length Required</h1></center>
> <hr><center>nginx/0.7.65</center>
> </body>
> </html>
>
> I am very confused on why jersey is not doing the right thing by adding
> the Content-Length header and why is the content in binary when
> I explicitly set it to String?
>
--
You received this message because you are subscribed to the Google Groups
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.