Skip to main content

While I have posted an article about how to POST an image using REST in Drupal 8... the journey there can be slow.  Crawling through the errors to eventually spot the missing link.  For me the how to is as important as the solution.

On the journey I did receive the following 404 Not Found error:

GuzzleHttp\Exception\ClientException: Client error: `GET https://yourdomain.com/sites/default/files/pictures/imagename01.jpg` resulted in a `404 Not Found` response: <!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "https://your (truncated...) in GuzzleHttp\Exception\RequestException::create() (line 113 of /var/www/vhosts/yourdomain.com/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php).

To dig out more information about this error, I went to the guzzle website http://docs.guzzlephp.org/en/stable/overview.html to see what I could track down.  On the requirements page I did notice the following:

  1. PHP 5.5.0
  2. To use the PHP stream handler, allow_url_fopen must be enabled in your system's php.ini.
  3. To use the cURL handler, you must have a recent version of cURL >= 7.19.4 compiled with OpenSSL and zlib.

On my environment the allow_url_fopen was set to false.  Filled with optimism, I altered the php.ini for my environment and ran another test.   However, the error remained.

If you have this error, then check that you have downloaded and enabled file_entity.  For me the missing link was not having installed file entity.  Read through post an image using rest article for more.

Related articles

Andrew Fletcher04 Apr 2025
Managing .gitignore changes
When working with Git, the .gitignore file plays a critical role in controlling which files and folders are tracked by version control. Yet, many developers are unsure when changes to .gitignore take effect and how to manage files that are already being tracked. This uncertainty can lead to...
Andrew Fletcher26 Mar 2025
How to fix the ‘Undefined function t’ error in Drupal 10 or 11 code
Upgrading to Drupal 10.4+ you might have noticed a warning in their code editor stating “Undefined function ‘t’”. While Drupal’s `t()` function remains valid in procedural code, some language analysis tools — such as Intelephense — do not automatically recognise Drupal’s global functions. This...
Andrew Fletcher17 Mar 2025
Upgrading to PHP 8.4 challenges with Drupal contrib modules
The upgrade from PHP 8.3.14 to PHP 8.4.4 presents challenges for Drupal 10.4 websites, particularly when dealing with contributed modules. While Drupal core operates seamlessly, various contrib modules have not yet been updated to accommodate changes introduced in PHP 8.4.x. This has resulted in...