Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i simulate REST post request with json data in browser

I have the web application where the frontend is in ExtJS and backend is in PHP.

The forms are build in Extjs and its making PUT and POST request to server for saving data.

The josn data is posted like this

{"id":"101","description":"user1","active":true}

Now for debugging i would like to directly call this URL in browser so that i can use var_dump for helpful messages.

As the request is AJAX by Extjs , so its very difficult to see messages through firebug.

Is there any way to make this request from browser and see response in rendred html.

I don't want to make form.

like image 719
user3147180 Avatar asked Jan 04 '14 15:01

user3147180


People also ask

How do I display JSON data in my browser?

Right click on JSON file, select open, navigate to program you want open with(notepad). Consecutive opens automatically use notepad.

How pass JSON object in POST request in browser?

To post data in JSON format using JavaScript/jQuery, you need to stringify your JavaScript object using the JSON. stringify() method and provide a Content-Type: application/json header with your request. Below is an example of sending JSON data using jQuery.

Can we call POST API from browser?

You cannot make a POST request by using a web browser, as web browsers only directly support GET requests. For this example, we assume that you have installed a REST client browser plugin. Chrome and Firefox both support open source Rest Client plugins that allow for the invocation of REST APIs from the browser.

How do I send a POST request with JSON payload?

To send the JSON with payload to the REST API endpoint, you need to enclose the JSON data in the body of the HTTP request and indicate the data type of the request body with the "Content-Type: application/json" request header.


2 Answers

If you are using Google Chrome you can use the Postman Extension. It allows you to send pretty much any type of data and see the results.

like image 93
Joseph Guadagno Avatar answered Sep 21 '22 15:09

Joseph Guadagno


For firefox you can use restclient plugin. Its also very easy to use, and userfriendly.

Also, if you know curl, you can do it programatically from PHP.

like image 26
Sabuj Hassan Avatar answered Sep 23 '22 15:09

Sabuj Hassan