I have trouble setting my Guzzle
headers.
try {
$res = $client->post($apiURL,
[
'headers' => [
'Content-Type' => 'application/json',
'accept' => 'application/json',
'Authorization' => 'Bearer ' . $token,
],
'body' => \GuzzleHttp\json_encode([
'query' => 'xxxyyy'
])
]
);
} catch (\GuzzleHttp\Exception\ClientException $e) {
dd($e->getResponse()->getBody()->getContents());
}
I get response from server that I need to check my access token, though it passes fine in the Postman when doing the same request. When checking Chrome inspector I am getting
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
I tried setting headers directly in the new Client()
constructor but I get the same response.
Package used: use GuzzleHttp\Client;