Java code for GET Request Retrieve JSON ExampleThis Java code snippet was generated automatically for the GET Request Retrieve JSON example.
<< Back to the GET Request Retrieve JSON example
What is JSON?
What is HTTP GET?
The HTTP GET request method is used to request data-specified resources from the server. The HTTP GET method is one of nine standard HTTP (Hypertext Transfer Protocol) methods. HTTP GET requests should only receive data and do not change the server's state.
How to send a GET request to get JSON data?
The client indicates to the server a list of supported formats using the HTTP Accept header. For example, browsers send GET requests with the Accept header in the following format:
The server selects the appropriate content type and informs the browser of its choice using the Content-type response header.
For the server to return a JSON response, the client must explicitly indicate that it expects to receive JSON data with the following header:
If the Accept header is not present in the request, the server assumes that the client accepts all media types.
GET request to get JSON data Example
Example of getting JSON data from ReqBin echo URL:
You will receive a response from the server: