Search code examples
postmanhttp-getrest-client

Postman is showing error message Incorrect URI


I am writing basic java RestAPI program to send "GET" request and parse the JSON response. I have added header Authorization as below which is needed to access my url.

request.addHeader("Authorization", "Basic ZXByOmNhc3Q=");

I have even used Postmanapp and RESTCLIENT add-on to check the response of URLs.

Response seems to be unstable.

Request runs successfully with 200code response sometimes and at times

I get {"code": 1, "message": "Incorrect URI"} in Java code and Postman.

where as RESTCLIENT shows "200 ok" response for the same url. entering the same url in browser is showing response similar to RESTCLIENT.

If its problem with the URL it shouldn't show error message all the time and it shouldn't be giving response even in RESTCLIENT add-on.

has anyone else faced same problem ,Please suggest some solution.


Solution

  • The Problem was with the Headers. Response for the URL was text/html

    RestClient addon in firefox by default accepts the Request and gives "content-type":"text/html" and "Content-Disposition: attachment; filename=export.txt" in the response headers

    where as in Advanced RestClient/Postman and Java code you need to explicitly add Request header "Accept: text/html" to get the output