I am trying to connect my Laravel infrastructure to my server using Guzzle. Each GET request is without parameters, but I have problems with POST.
This query using cURL works fine:
curl -i -X POST -H 'Content-Type: application/json' -d '{"email":" user@domain.com ", "pwd":"xxxxxx"}' http://www.example.com:1234/rest/user/validate
And here is what I tried to implement using Guzzle:
$response = GuzzleHttp\post('http://www.example.com:1234/rest/user/validat', [ 'headers' => ['Content-Type' => 'application/json'], 'body' => ['{"email":" user@domain.com ", "pwd":"xxxxxx"}'] ]); print_r($response->json());
When I make a request, I get the following error:
[status code] 415 [reason phrase] Unsupported Media Type
I think this is due to the body , but I do not know how to solve it.
Any idea?
source share