0

One can figure out from a webpage the parameters used for a POST request, e.g. How to view the address of the POST request made when an HTML button is clicked?

Is this possible for POST method to enter the url with parameters in the address bar or maybe from the debugger console?

For get request, one inserts a ? between address and parameters, e.g.

https://www.w3schools.com/action_page.php?fname=Albert&lname=Einstein.

(The analog post form calls the same script.)

3 Answers3

0

Sure it is possible for POST method to pass parameters in the address.

Set up a form to POST with an action /foo?bar=bat and the server will get POST form parameters and the query string parameters.

It would be trivial to create the action dynamically so that the query string in the action contains the form parameters. For example - here the when the form is submitted the POST data is appended to the query string before the form is posted via ajax. So you get the post parameters both in the URL and in the body data.

html

<!DOCTYPE html>
<html>
  <body>
    <form action="/something">
      <label for="fname">First name:</label><br>
      <input type="text" id="fname" name="fname" value="John"><br>
      <label for="lname">Last name:</label><br>
      <input type="text" id="lname" name="lname" value="Doe"><br><br>
      <input type="submit" value="Submit">
    </form>
  </body>
</html>

js

$("form").submit(function(e) {
  e.preventDefault();
  let f = $(e.currentTarget);
  $.ajax({
    type: "POST",
    url: `${f.attr("action")}?${f.serialize()}`,
    data: f.serialize(),
    success: function() {
      //success message maybe...
    }
  });
});

That said this is probably not a good idea at all.

Fraser
  • 15,275
  • 8
  • 53
  • 104
0

Here is my javascript solution.

E.g. the form on http://vizier.u-strasbg.fr/viz-bin/VizieR requires post.

The following command can be run in the debugger console. It manipulates one input field.

form=document.getElementsByName("form0")[0]; form.isource.value="Gaia";
form.target="_blank"; form.submit()

The url is already inherited from form.action.

-1

It's not possible.

The POST params can be passed only via the request body.

You can use some kind of API client tool such as Postman, Paw or just use plain curl.