I need to do a post call to a web service, with "authorization" field in the header, but I always get 500 Internal Server Error from the server.
The strange thing is if I do the same call with Postman I get the result.
I thought that my guzzle call is wrong.
This is the code:
$client = new Client([
'verify' => false
]);
try {
$res = $client->post(
$base_uri . $uri, [
'headers' => [
'content-type' => 'application/json',
'authorization' => $login['token'],
],
'form_params' => []
]
);
echo 'OK';
return json_decode($res->getBody(), true);
} catch (GuzzleHttp\Exception\ClientException $e) {
echo 'ClientException';
} catch (Exception $exc) {
echo 'Exception';
}
This catches the "Exception" exception.
I attach the image of postman call that does not get the error.
I checked:
- the uris are the same;
- the authorization parameters are the same;
- the body in postman is empty.