https://api-docs.igdb.com/?ruby#game I'm trying to implement calls to this api using the http_client_manager models. I've attached images of my operation defined in yaml, and the code I'm trying to use. The issue surrounds the body of the call. I'm not sure how to pass it in as a raw text. I can make the call correctly like this:
$response = \Drupal::httpClient()->post("https://api.igdb.com/v4/games",
[
'headers' => [
'Content-Type' => 'application/json',
'Client-ID' => $config->get('igdb_api_key'),
'Authorization' => 'Bearer ' . $config->get('igdb_access_token'),
],
'body' => 'search "' . $node->getTitle() . '"; fields url;',
]);
$response_body = $response->getBody()->getContents();
However when I try to do this
$body = 'search "' . $node->getTitle() . '"; fields url';
$response = $api->getGames($body);
// in getGames()
$args = [
'Client-ID' => $config->get('igdb_api_key'),
'Authorization' => 'Bearer ' . $config->get('igdb_access_token'),
'body' => $body,
];
return $this->call(Games::GET_GAMES, $args)->toArray();
I get the response
There was an error executing the GetGames command: Client error: `POST https://api.igdb.com/v4/games` resulted in a `400 Bad Request` response:
[
{
"title": "Syntax Error",
"status": 400
}
]
Closed: outdated
9.3
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.