Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (10.2k points)
I would like to make a simple HTTP POST using JSON in Java.

Let's say the URL is www.site.com

and it takes in the value {"name":"myname","age":"20"} labeled as 'details' for example.

How would I go about creating the syntax for the POST?

I also can't seem to find a POST method in the JSON Javadocs.

1 Answer

0 votes
by (46k points)

It's probably easiest to use HttpURLConnection.

http://www.xyzws.com/Javafaq/how-to-use-httpurlconnection-post-data-to-web-server/139

You'll use JSONObject or whatever to construct your JSON, but not to handle the network; you need to serialize it and then pass it to an HttpURLConnection to POST.

Related questions

0 votes
1 answer
asked Nov 20, 2019 in Java by Nigam (4k points)
0 votes
1 answer
asked Oct 9, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
asked Jul 24, 2019 in Java by Nigam (4k points)
0 votes
1 answer

Browse Categories

...