I'm trying to fetch data by GET request with using Guzzle client. I'm using both header with JWT token and query params like below:
function fetchUserByEmployeeId(string $employeeId): JsonResponse
{
$headers = $this->getHeaders();
$query = ['$filter' => "employeeId eq $employeeId", '$select' => 'displayName,givenName,postalCode,employeeId,id'];
try {
$result = $this->client->request('GET', self::FIND_USER_BY_EMPLOYEE_ID_URL, [
'headers' => $headers,
'query' => $query,
'debug' => true
]);
return JsonResponse::fromJsonString($result->getBody()->getContents());
} catch (RequestException $exception) {
throw $exception;
}
}
Unfortunaletely I've received an error like below:
If I delete $query it will work. Is there something wrong with my query params? I have no idea. Based on Guzzle documantation it seems to be ok: https://docs.guzzlephp.org/en/stable/request-options.html#query