I use the client-Object to simulate and test my Silex-Webservices. How can I send a JSON-Body with the PUT-method?
My idea was:
$crawler = $this->client->request('PUT', '/test', array(), array(), array(), '{"id":"34"}');
That does not work. :(
Please try to use this code:
$client->request(
'PUT', '/test', array(), array(),
array(
'CONTENT_TYPE' => 'application/json',
'HTTP_X-Requested-With' => 'XMLHttpRequest'
),
'{"id":"34"}'
);
Thanks Dimitry, not exactly what I was looking for, but a great hint to find the solution:
$client->request(
'PUT', '/test', array(), array(),
array(
'CONTENT_TYPE' => 'application/json',
'HTTP_X-Requested-With' => 'XMLHttpRequest'
),
'{"id":"34"}'
);
Your solution had one empty array to much and the idea was to pass in JSON as string!
Thanks a lot! Cheers