Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending POST parameters with Postman doesn't work, but sending GET parameters does

Tags:

php

postman

I'm trying to test a simple PHP page using the Chrome extension Postman. When I send URL parameters, the script works fine (eg the variables are available in the $_REQUEST parameter). When I send them as x-www-form-urlencoded parameters, the $_REQUEST parameter only contains the PHPSESSID.

The script:

<?php
var_export($_REQUEST);
?>

When I send URL parameters, $_REQUEST includes them: URL parameters

But when I send them as POST variables, $_REQUEST doesn't include them: enter image description here

What am I missing?

like image 977
whiterook6 Avatar asked Jun 11 '14 17:06

whiterook6


People also ask

How do you pass parameters in Postman POST?

Right-click selected text, and choose EncodeURIComponent to manually encode a parameter value. To send a path parameter, enter the parameter name into the URL field, after a colon, for example :id . When you enter a path parameter, Postman will populate it in the Params tab, where you can also edit it.

Can we send parameters in POST request?

In a POST request, the parameters are sent as a body of the request, after the headers. To do a POST with HttpURLConnection, you need to write the parameters to the connection after you have opened the connection.

How do you pass multiple parameters in Postman POST request?

Enter the same URL in the Postman text field; you will get the multiple parameters in the Params tab. Even you can write each of the parameters and send a request with multiple parameters.


3 Answers

I was setting the url in Postman to be http:// but Apache was redirecting to https:// and somehow the POST variables were being dropped along the way.

After I changed it to https://, the POST variables worked properly.

See also: https://stackoverflow.com/a/28461500/704803

like image 113
andrewtweber Avatar answered Oct 19 '22 13:10

andrewtweber


I faced the same issue in PostMan and Advance REST Client both. I checked through fiddler and found that my request payload is not converted into JSON format.

I am passing my data in Body as x-www-form-urlencoded enter image description here

You can fix it by using Content-Type as application/x-www-form-urlencoded in request header. enter image description here

like image 103
Arvind Dhasmana Avatar answered Oct 19 '22 12:10

Arvind Dhasmana


Simply use the Body Tab and enter the post parameters there. Note that Body Tab is disabled if Get is selected.

like image 26
AndroidLearner Avatar answered Oct 19 '22 13:10

AndroidLearner