Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to easily test POSTs when making a website?

Tags:

post

testing

What's an easy way to test sending POST requests when making a website? I can easily send GET requests by typing it in the URL (example.com/?foo=bar&bar=baz) but what's an equivalently easy way to send POST requests?

like image 629
Claudiu Avatar asked May 10 '11 15:05

Claudiu


3 Answers

Curl CLI

curl -d "param1=value&param2=value2" http://www.example.com/resource

or

curl -F "[email protected]" http://www.example.com/resource

https://superuser.com/questions/149329/how-do-i-make-a-post-request-with-curl/149335#149335

But I always just use a test script with a http request class. I find you get finer granularity over headers, formats, verb, etc. And of course you can put that code into a unit test after you're done. I use this class that I wrote ( https://github.com/homer6/altumo/blob/master/source/php/Http/OutgoingHttpRequest.md ) but I hear that the zend request class is quite good too.

like image 90
Homer6 Avatar answered Sep 21 '22 08:09

Homer6


You can use Fiddler or a Browser plugin like FireFox Tamper Data.

Or you can just create a form and submit it from any .HTML page:

<form action="TestPage.html" method="POST">
    <input name="name1" value="value1" />
    <input name="name2" value="value2" />
    <input type="submit" value="POST!" />
</form>
like image 36
mellamokb Avatar answered Sep 19 '22 08:09

mellamokb


you can use any inspector to do that like fireFox

make request type post >> put your url >> put parameters in request body section

enter image description here

like image 39
Mahmoud Abdallah Avatar answered Sep 22 '22 08:09

Mahmoud Abdallah