How can one resolve the error related to the XML declaration when using Guzzle in PHP?

When using Guzzle in PHP to make HTTP requests, you may encounter an error related to the XML declaration. This issue can be resolved by setting the 'decode_content' option to false in the Guzzle client configuration. This prevents Guzzle from attempting to decode the response as XML, which can cause conflicts with the XML declaration.

use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'http://example.com',
    'decode_content' => false
]);

$response = $client->get('/api/data');

$body = $response->getBody()->getContents();

// Process the response body as needed