82

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?

Shahzad Barkati
  • 2,491
  • 6
  • 23
  • 32
whiterook6
  • 3,130
  • 3
  • 31
  • 65
  • 3
    Did you find an answer to this issue? I'm having the same problem. – Stuart Oct 14 '14 at 14:10
  • No, I haven't yet. It might well have been something to do with our API routing, possibly only sending over some of the parameters but not all of them? I'm not sure. – whiterook6 Oct 14 '14 at 21:18
  • Thanks for the response - I've just given up on it just unfortunately... :/ – Stuart Oct 15 '14 at 12:18
  • Have the same problem :( – Aldekein Oct 15 '14 at 15:33
  • You say you have some routing, but really, do you? Did you try to just setup a server without any application and put a file like that (so without routing)? Also, I can see you have some headers in your POST request. Did you try removing them? – Kelu Thatsall Feb 05 '15 at 23:34
  • Did you try uninstalling programs that are using network? It might be one of the reason of port conflict – neferpitou Mar 08 '15 at 03:55
  • 4
    I found this answer: http://stackoverflow.com/a/28461500/704803. I was redirecting from HTTP to HTTPS and it was causing the POST variables to be lost. When I told Postman to go directly to the HTTPS url, it worked – andrewtweber Apr 22 '15 at 19:13

11 Answers11

108

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

Community
  • 1
  • 1
andrewtweber
  • 22,739
  • 21
  • 84
  • 107
  • 3
    This was the issue I had as well. nginx was redirecting via 302 to https and the POST parameters were dropped on the redirect. Manually setting the URL to https:// worked. – anothermh Aug 06 '15 at 19:28
  • I think this is the *bug* in Postman. Working for HTTPS and not Working for HTTP. I have seen there code generated by their functinality `Generate Code` which generated wrong code for Python Requests. querystring = {"username":"data1","mydata":"9232"} payload = "" headers = { 'cache-control': "no-cache", 'postman-token': "aeb70e40-c12a-f713-1d8d-596b8cf976af" } response = requests.request("POST", url, data=payload, headers=headers, params=querystring) print(response.text) I think this is buggy. – Harsh Vardhan Ladha Jun 01 '16 at 01:39
  • I am getting same error but this theory not applying. its not working for both. – Heemanshu Bhalla Apr 11 '19 at 09:13
  • Thanks. This one saved my time. – Rakibul Islam May 14 '20 at 06:43
  • thank you very much, I've been looking for a way to solve this for almost a month – Salz May 10 '22 at 08:27
102

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

Arvind Dhasmana
  • 1,336
  • 2
  • 9
  • 7
  • 1
    Many thanks @Arvind, changing header to ```application/x-www-form-urlencoded``` actually works! IMHO, this should be accepted as an answer :) – Rafal Gałka Sep 09 '15 at 18:11
  • 2
    Maybe someone is facing the same issue: for me, using `localhost/something` on POSTMAN wasn't working, but after adding `/` to the end, php started getting the values from `POST` and from `php://input`. I had to use `localhost/something/` to make it work. – FirstOne Apr 22 '16 at 02:43
  • 4
    Yes! This fixes the issue. Actually, `PARAMS` field near `URL` sets the `GET` data not `POST` data. And the keyword `PARAMS` is always being related to `GET` and `DATA` being related to `POST` for passing the data. I think peeps at PostMan should fix this to change automatic, or add the `DATA` button automatically. – Harsh Vardhan Ladha Jun 01 '16 at 01:47
  • @FirstOne you should at that as an answer. I got the same problem also – ismailsunni Sep 26 '17 at 14:11
  • @FirstOne - that worked because adding `/` at end avoided a redirect. POSTMAN loses POST parameters on a redirect. – ToolmakerSteve Aug 09 '21 at 14:55
26

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

isherwood
  • 52,576
  • 15
  • 105
  • 143
AndroidLearner
  • 1,360
  • 7
  • 24
  • 40
15

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

my php was seeing jack all in the request post. It wasn't until i change the content-type to application/x-www-form-urlencoded with the JSON in the RAW textarea and its type as JSON, did my PHP app start to see the post data. not what i expected when deal with raw json but its now working for what i need.

postman POST request

mushcraft
  • 1,698
  • 1
  • 18
  • 27
8

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

isherwood
  • 52,576
  • 15
  • 105
  • 143
Satish Shinde
  • 2,718
  • 1
  • 21
  • 40
  • 2
    For me was to select `Body` tab and select `x-www-form-urlencoded` and below that selection you can find key/value entry where you put your POST key/value data. By the way my Postman version is 4.10.4 – Zamrony P. Juhara Mar 25 '17 at 04:37
4

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.

John O'Connor
  • 5,164
  • 2
  • 21
  • 29
4

Sorry if this is thread Necromancy, but this is still relevant today, especially with how much APIs are used!

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

Lee
  • 437
  • 6
  • 6
4

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

Form data request

Choxmi
  • 1,424
  • 4
  • 26
  • 45
1

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

user2229618
  • 105
  • 1
  • 11
0

Sometimes Version problem in 'Postman' :

I have face 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 fix this problem, Once I uninstall the oldest version of postman and installed with latest version.

Mohammed Yasin
  • 458
  • 7
  • 11
-1

I was also facing this issue and I just add www in url like -

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