IMB
IMB

Reputation: 15889

How to get contents of a PUT request?

If a client sent a PUT request with an array for example:

$a = array('age' => 18);
$rest->put('/api/users/9', $a);

How does your rest API get the $a array?

Upvotes: 1

Views: 238

Answers (2)

zzzzBov
zzzzBov

Reputation: 179046

You can read the request body at php://input, but be warned that it's volatile and can only be read once*.

file_get_contents('php://input');‌​

You'll then need to parse this as a URL to use it as an array.

* details are on the linked page

Upvotes: 2

Paolo del Mundo
Paolo del Mundo

Reputation: 2121

It should be in the body of the request.

Upvotes: 0

Related Questions