Search code examples
jsonrestrestletpostman

Querying a JSON REST Service with POSTMAN/Rest Client


I have a simple RESTLET Service which returns a JSON representation, as shown below:

@Override
    @Post("json")
public Representation helloWorld() {
    Representation representation = new JacksonRepresentation<Hello>(new Hello("Hello World"));
    representation.setMediaType(MediaType.APPLICATION_JSON);
    representation.
    return representation;
}

When I query this using cURL I get the response as expected:

{"greeting":"Hello World"}

However I do not get a response when I use the browser or POSTMAN or indeed any other web REST client. I get the response 'Could not get any response' from POSTMAN.

The preview of the POSTMAN request is:

POST /testingrestlet/hello HTTP/1.1
Host: 127.0.0.1:6000
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 5141cd87-505c-e813-0045-3b7f4aa54144

I would at least have expected a REST client such as POSTMAN to work, or am I missing something?

Any help appreciated.

Regards


Solution

  • With help from Thierry's comments the issue was traced down to Google Chrome blocking requests to port 6000 as it considers them unsafe. The error was only visible in Chrome Debug mode where the ERR_UNSAFE_PORT error was reported. Changing to a higher port resolved the issue! Detail of this error can also be found here: https://superuser.com/questions/188006/how-to-fix-err-unsafe-port-error-on-chrome-when-browsing-to-unsafe-ports