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:
- PHP 5.5.0
- To use the PHP stream handler,
allow_url_fopenmust be enabled in your system's php.ini.
- 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.