By smerny

2016-08-18 00:09:20 8 Comments

I've got Postman (the one that doesn't open in Chrome) and I'm trying to do a POST request using raw json.

In the Body tab I have "raw" selected and "JSON (application/json)" with this body:

    "foo": "bar"

For the header I have 1, Content-Type: application/json

On the PHP side I'm just doing print_r($_POST); for now, and I'm getting an empty array.

If I use jQuery and do:

    "type": "POST",
    "url": "/rest/index.php",
    "data": {
        "foo": "bar"
}).done(function (d) {

I'm getting as expected:

    [foo] => bar

So why isn't it working with Postman?

Postman screenshots:

enter image description here

and header:

enter image description here


@Itachi 2019-01-29 01:09:40

Just check JSON option from the drop down next to binary; when you click raw. This should do

skill synon pass json to postman

@smerny 2019-01-29 07:16:58

this is a fairly old post.. but if you look at the question you'll see that I did exactly that. you may want to read the question, the selected answer, and the comments on the selected answer to understand the problem and solution better.

@Neo 2017-03-29 05:48:44

I was facing the same problem, following code worked for me:

$params = (array) json_decode(file_get_contents('php://input'), TRUE);

@meda 2016-08-18 00:32:35

Unlike jQuery in order to read raw JSON you will need to decode it in PHP.

print_r(json_decode(file_get_contents("php://input"), true));

php://input is a read-only stream that allows you to read raw data from the request body.

$_POST is form variables, you will need to switch to form radiobutton in postman then use:


To post raw json with jquery:

    "url": "/rest/index.php",
    'data': JSON.stringify({foo:'bar'}),
    'type': 'POST',
    'contentType': 'application/json'

@meda 2016-08-18 02:02:50

yes exaclty posting json vs post variables are different

@Jaroslav Štreit 2018-06-28 10:17:02

Install Postman native app, Chrome extension has been deprecated. (Mine was opening in own window but still ran as Chrome app)

@jhpratt 2019-01-01 07:36:22

This doesn't answer the question.

@Jaroslav Štreit 2019-01-02 08:25:27

@jhpratt actually it does. I had same problem. When used Postman app, it worked. Question is: So why isn't it working with Postman?

@CoredusK 2017-04-27 09:22:49

meda's answer is completely legit, but when I copied the code I got an error!

Somewhere in the "php://input" there's an invalid character (maybe one of the quotes?).

When I typed the "php://input" code manually, it worked. Took me a while to figure out!

@Charlie Stanard 2018-08-20 18:24:08

Glad I scrolled down a little further and saw this - I was having the same issue. Good find!

@smerny 2019-02-14 16:19:50

It looks like someone fixed it in an edit to meda's post. But I looked at the edit history and found that the original post had 200c 200b (zero width characters) between the "n" and "p" in "input". Not sure how he ended up with that, but it's fixed now.

Related Questions

Sponsored Content

21 Answered Questions

34 Answered Questions

[SOLVED] Reference - What does this error mean in PHP?

15 Answered Questions

[SOLVED] How to POST raw whole JSON in the body of a Retrofit request?

5 Answered Questions

[SOLVED] How to get POSTed json in Flask?

7 Answered Questions

[SOLVED] HTTP POST with URL query parameters -- good idea or not?

  • 2009-03-04 18:42:52
  • Steven Huwig
  • 337588 View
  • 420 Score
  • 7 Answer
  • Tags:   rest http

11 Answered Questions

[SOLVED] Fetch: POST json data

12 Answered Questions

[SOLVED] JavaScript/jQuery to download file via POST with JSON data

2 Answered Questions

[SOLVED] Send POST data with raw json with postman Express

1 Answered Questions

[SOLVED] jQuery posting valid json in request body

2 Answered Questions

[SOLVED] Codeception - POST raw JSON string

Sponsored Content