Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting connection time out - JSON rest Client for POST request  RSS feed

 
Eshwin Sukhdeve
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I want to write one REST client program for POST request ,request and response is in JSON Format.



Line OutputStream os = httpConnection.getOutputStream();
I am getting connection time out problem
 
Anjaneya Reddy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please try below code.

OutputStreamWriter writer =new OutputSreamWriter(httpConnection.getOutputStream());
writer.write(input);
 
Eshwin Sukhdeve
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anjaneya ,

I have resolved the connection time out issue ,it was some proxy problem.

But now I a getting 500 error in

if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
throw new RuntimeException("Failed : HTTP error code : "
+ httpConnection.getResponseCode());
}

I have used the below code.even though I am getting same error.

OutputStreamWriter writer =new OutputSreamWriter(httpConnection.getOutputStream());
writer.write(input);


I have tested the service through REST client broswer ,there I am getting correct result ,but through java I am getting 500 error
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!