Reputation: 87
This is my code:
<?php
if(isset($_POST["test"]))
echo $_POST["test"];
if(isset($_GET["test"]))
echo $_GET["test"];
?>
My question is: why POST request doesn't work?
I have tried different parameters in the body and the header and nothing works.
POST request in Postman fails:
Upvotes: 1
Views: 19573
Reputation: 11
Your request might be redirected:
- All of your requests are sent as GET requests, no matter which HTTP request method you select.
- The original HTTP request method you selected is not preserved when there is a redirect between HTTP and HTTPS."
https://support.postman.com/hc/en-us/articles/211913929-My-request-is-redirected-to-a-GET-request
Upvotes: 1
Reputation: 21
In the header tab, set "Content-Type"-"application/x-www-form-urlencoded"
In the body tab, choose form-data
Enter your key/value pairs. These represent the name parameter in your PHP or HTML form and their expected values
Change request type to POST and enter the url of the script that will process the form. This is the full url of the action parameter in your form
Upvotes: 2
Reputation: 41
First of all you have to set the headers as "Content-Type"-"application/x-www-form-urlencoded" and disable "Content-Type"-"application/json".
After that in the body tab select "x-www-form-urlencoded" field not the "raw" field and enter the values you need to post as the post request.
Don't forget to change the request type to POST.
Upvotes: 3