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

json Post methiod in Java  RSS feed

 
Bogdan Mocanu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to acces an REST api using a POST method,but each time I access it it gives me java.net.socketException . I can acces the API from other code,such as PHP.
Those are the params.

{"auth":{"user": {"id": "bla","password": "bla"},"method": "user","website": "website.net"}}

And here is my code:



Thank you!
 
Ron McLeod
Saloon Keeper
Posts: 1600
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your JSON is mal-formed - not sure if that is causing the problem or it is something else.

String urlParameters = "{\"auth\":{\"user\":{\"id\":\"bla\",\"password\":\"bla\"}\"method\":\"user\",\"website\":\"http://website.net/\"}}";
                                                                                 ^

If you can post the console output including stack trace when the exception is thrown, it would easier to help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!