I am using Guzzle as my PHP HTTP client to perform api-calls. This worked great so far, for retrieving my access-token for example.
However, now that I am trying to perform a query search I get a strange Error:
SELECT+Name+FROM+Account\n ^\nERROR at Row:1:Column:6\n unexpected token: '+'
This is my code for performing my request:
try {
$response = $client->get( 'services/data/v55.0/query/', [
RequestOptions::HEADERS => [
'Authorization' => 'Bearer ' . $accessToken,
'Content-Type' => 'application/json'
],
'query' => [
'q' => 'SELECT+Name+FROM+Account',
],
/*'debug' => true*/
] );
$data = json_decode( $response->getBody(), true );
return $data;
}
catch ( \Exception $exception ) {
echo $exception;
/*refreshAccessToken();*/
/*continue;*/
}
As pointed out by @sfdcfox, guzzle encodes my query string. Unfortunately, when I pass my query directly to my url, or append it to the request using the JSON requestOption it does not get recognized by Salesforce. How can I perform my query with guzzle without encoding my query, and is it even possible?