I am working on rest web service project currently actually in rest client in mozilla (chrome://restclient/content/restclient.html)it will get the {"id":"1234"} as request json and fetch the details of the id and provide all the details for id from database and convert into json array and finally its stored in responsetoservice object.
When i hit the service url the request reaches the server and status is 200 OK. But the response body in json is not visible in the response body(Raw) in the Rest client. But when i view the logs the json response is printed.
Can anyone help me regarding this stuck up on this. Please help me on why the response json is not viewable in rest client int mozilla
The problem could be inability of your browser to parse and show the response, have a look at https://weblog.west-wind.com/posts/2011/Apr/01/Displaying-JSON-in-your-Browser
Related
Opening https://www.coinome.com/exchange/data.json in browser shows a json,but while trying to fetch response by making a GET request,the returned response is in html format.
How to get JSON response instead of html response?
that's because the first time you perform the request to that url, the server returns an html form to check whether youare human or not.
Then after you compile and submit the form a cookie is returned.
You have to save that cookie and redo the request to the same url while putting the cookie in the request header in order to get the response in json format.
I am exposing a Rest based POST API and have to read few parameters in the body along with header. I am able to fetch the query string (header) parameters using HTTP Input node query string parser. As i have configured Input parser to JSON, it can not parse the incoming message and gives a runtime exception :
JSON parsing errors have occurred
Content-Type is set to :
application/x-www-form-urlencoded
I am very newbie with Rest/ JSON services on IIB. Help would be greatly appreciated.
Say for example I'm try to make a GET Request to www.testjson.com/json, However the response is retrieved from a different domain URL e.g. www.testjson.com/confirmJson.
Does Spring mvc support this, specifically restTemplate.exchange functionality.
I am currently doing this sort of thing, but I am getting an 500 status code (internal server error) and have no way of finding out what exactly is causing the error.
So can RestTemplate actually manage the redirect and provide the necessary JSON response or does it actually wait for the response from the url you provide hence the reason for getting the 500 internal server error?
It is possible to let a RestTemplate automatically follow a redirect.
The server must respond with a Http 3xx and the location header set.
The RestTemplate 'understands' this response and issues a new GET request to the returned location.
This should work with default spring configuration.
See also follow-302-redirect-using-spring-resttemplate
I'm using content negotiation to return a JSON object from some WebAPI controllers.
I found this question
How to return Json object on Web API Controller
Here some of the people answered seem to agree that you shouldn't rely on negotiation but should create a new HttpContent class for the JSON return.
Why is this please? As a beginner content negotiation seems to work well.
I have searched for this answer, but can't find an explanation.
ASP.Net Web API in its purest form is intented to create REST ful web services.
As per REST full standards client should have the ability to decide whether the response should be in XML/JSON response. And this can be achieved using Content-negotiation header in the request.
That means your understanding is correct and using Content negotiation you can decide whether you require XML/JSON response in ASP.Net Web API.
If I have to give you example of this then please create web api by default template. This contain value controller.
Now go to chrome browser and request the data and go to IE and request the data. In chrome you will get XML data while in IE you will get JSON data. ( It ask for download json).
Now if you use tool like fiddler and look at request then you will find difference in request header of both browser.
So if you are sure that you always need json data then it is good to return JSON data from controller action it self. If you don't want to do that and still want all your request to be return JSON then please set header "Accept" with application/json.
http://www.asp.net/web-api/overview/formats-and-model-binding/content-negotiation
In short if you want to your api always communicated by json data then it is good to return result of json type rather then depend on content negotiation.
I was wondering if someone could tell me why I can't see the json response from a request that is also of type json in the JMeter View Results Tree. I know that the response is there because I use a regular expression to extract data (I wrote the reg ex based on result returned in Firebug). So the data can be extracted from the json response it just doesn't display in View Result Tree. I can see the json response for another request for a different app I performance test with JMeter, but that particular request is an ajax request. not sure
Add a sample writer and display content here.
http://jmeter.apache.org/usermanual/component_reference.html#Simple_Data_Writer
You will see the issue
HI there any one who looks in this post for jmeter, you may be bit worried when you cant find answers in internet regarding how to log your response when you sent a request , here is the solution and simple as it is...
just add a line like below.
result.setResponseData("put any content here to be displayed as String.", "UTF-8");
and check your response will be cool as you done.