whiterook6
whiterook6

Reputation: 3544

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

I'm trying to test a simple PHP page using the Chrome extension Postman. When I send URL parameters, the script works fine (for example, 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?

Upvotes: 87

Views: 232704

Answers (13)

Nitesh S Chauhan
Nitesh S Chauhan

Reputation: 205

I was also facing this issue and I just added www in the URL, like:

https://www.your-domain.com/

Upvotes: -2

mushcraft
mushcraft

Reputation: 2234

Check your content-type in the header. I was having an issue with this sending raw JSON and my content-type as application/json in the Postman header.

My PHP code was seeing jack all in the request post. It wasn't until I changed the content-type to application/x-www-form-urlencoded with the JSON in the RAW textarea and its type as JSON, did my PHP application start to see the post data. Not what I expected when dealing with raw JSON, but it’s now working for what I need.

Postman POST request

Upvotes: 16

Mohammed Yasin
Mohammed Yasin

Reputation: 527

Sometimes it is a version problem in Postman:

I have faced the same problem. While sending the data using the oldest version of postman.

That time I have received the empty json data in server side. And I have fixed this problem. Once I uninstall the oldest version of postman and installed with latest version.

Upvotes: 0

Don Ejeh
Don Ejeh

Reputation: 541

If you are using the Laravel Request method, add your

Accept:Application/json

to your Postman header.

Enter image description here

Upvotes: 0

Jannick Breunis
Jannick Breunis

Reputation: 343

I came here again after I created an endpoint which also would not find the given POST parameters. But the problem now was the missing forward slash... So that's another one to look out for.

Upvotes: 0

user2229618
user2229618

Reputation: 125

For me, the server was expecting HTTPS requests, but I didn't specify that in the URL. The hook would reach the server, but the body would be empty.

Upvotes: 2

Lee
Lee

Reputation: 447

An issue I had was: I didn't know that under the 'Key' column you need to put: 'Content-Type'; I thought this was a User Key for when it came back in the request, which it isn't.

So something as simple as that may help you. I think Postman could word that column better, because I didn't even have to read the documentation when it came to using Fiddler; whereas I did with Postman.

Postman picture

Upvotes: 4

Choxmi
Choxmi

Reputation: 1664

Instead of using the raw JSON body, try using form-data.

Form data request

Upvotes: 6

Satish Shinde
Satish Shinde

Reputation: 2996

When you send parameters by x-www-form-urlencoded then you need to set the header for the request as using Content-Type as application/x-www-form-urlencoded.

Upvotes: 7

Arvind Dhasmana
Arvind Dhasmana

Reputation: 1446

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

Upvotes: 108

andrewtweber
andrewtweber

Reputation: 25549

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: How to send POST variable in POSTMAN

Upvotes: 128

Salman
Salman

Reputation: 1380

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

Upvotes: 26

John O&#39;Connor
John O&#39;Connor

Reputation: 5274

I was having the same problem. To fix it I added the following headers:

Content-Type: application/json

I had to manually add the content type even though I also had the type of "json" in the raw post field parameters.

Upvotes: 4

Related Questions