Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to pass json format in browser's url address bar? (GET method)

want to test my url service in browser but need to pass json format data.

I tried the below but no success: http://locahost:8042/service/getinfo?body={"name":"H&M"}

or any tool that can be use to pass json formatted test data?

UPDATES1 I mean is to pass the json formatted data manually in browser's url address bar. Like as my example above. This is for quick testing only not for implementation.

like image 484
eros Avatar asked Nov 10 '11 06:11

eros


People also ask

Can you pass JSON in a GET request?

To answer your question, yes you may pass JSON in the URI as part of a GET request (provided you URL-encode).

Is it possible to send JSON request with HTTP GET method?

To get JSON from a REST API endpoint, you must send an HTTP GET request and pass the "Accept: application/json" request header to the server, which will tell the server that the client expects JSON in response.


2 Answers

Yes, you certainly can pass JSON in a URL Querystring. You just have to URLencode the JSON string first. As @dmn said, the data is probably better passed via POST because of GET's size restrictions.

like image 86
Jonathan Wilson Avatar answered Sep 29 '22 19:09

Jonathan Wilson


The { and } characters are considered unsafe for unencoded use in a URL.

http://www.faqs.org/rfcs/rfc1738.html

like image 43
Stephen Wrighton Avatar answered Sep 29 '22 21:09

Stephen Wrighton