# Slim 3 how to read post variables from body

**URL:** <https://discourse.slimframework.com/t/slim-3-how-to-read-post-variables-from-body/766>\
**Category:** Questions\
**Created:** [September 28, 2016, 12:44pm UTC](https://discourse.slimframework.com/t/slim-3-how-to-read-post-variables-from-body/766 "2016-09-28T12:44:42Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![llvdl](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/llvdl/32/78_2.png) [@llvdl](https://discourse.slimframework.com/u/llvdl)\
**Post date:** [October 5, 2016, 5:28pm UTC](https://discourse.slimframework.com/t/slim-3-how-to-read-post-variables-from-body/766/9 "2016-10-05T17:28:27Z")

</div>

Hello Anupam,

You are probably getting `NULL` when calling `Request::getParsedBody` because there is no content header set in the request indicating that the data posted is JSON. If you add the header “Content-Type: application/json” when making the POST request, the JSON data will be parsed.

If you have no control over the headers that are sent with the POST request, you can add the content type header yourself before calling `Request::getParsedBody` or call `json_decode` yourself, e.g.

```php
$data = json_decode($req->getBody());
var_dump($data->username);
var_dump($data->age);

```

There is a thread on this issue at [Parse JSON when no Content Type comes in Request header](http://discourse.slimframework.com/t/parse-json-when-no-content-type-comes-in-request-header/719/4)

---

_[View the full topic](https://discourse.slimframework.com/t/slim-3-how-to-read-post-variables-from-body/766)._
