X-Cld-Error header for general debugging
When experiencing an error accessing an asset's URL, you can check the HTTP response header to get more details about the error. This applies to many types of error, and there's more information about general debugging in the article Debugging why an image or video doesn't load in your application or site.
Errors specific to the Remote Image Fetch URL feature
When fetching an image from a remote URL, the error may be with the URL that you've created, but it's also possible that the URL was valid and your account configuration disallowed the request, or that Cloudinary received an error from the remote server.
Account configuration
It's possible to 'restrict' the ability to fetch images into your account using unsigned URLs, and this can cause unexpected errors when using the Remote Image Fetch URL feature:
If you try to fetch a new image using an unsigned URL while the feature is restricted, you may see a specific error:
x-cld-error: Images of type fetch are restricted in this account
Or a generic error:
x-cld-error: Resource not found
In each case, you can resolve the issue by signing the URL, by removing the restriction in your security settings, or by using the authenticated "explicit" API method to trigger fetching of the new image.
Parameter escaping
As an example of where the URL may be incorrect, when trying to access the following link:
http://res.cloudinary.com/demo/image/fetch/https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTm_o8s5J9-z2SAZ5yGfsD-fbZox4wGv1Fzlt0DIf4qrLbfgMZS5w
you'll see the following HTTP response header:
x-cld-error: Resource not found - https://encrypted-tbn1.gstatic.com/images
This error is returned because the URL that was requested from Cloudinary includes query string parameters (after the "?") which are not part of our API, and are usually ignored by Cloudinary.
When we make a request to the remote server, those are not included and we're receiving an HTTP 404 ('not found') error from the remote server. If query string parameters should be included on the request to the remote URL, those must be escaped in the request that you make to Cloudinary, and will become part of the asset's public_id in your Cloudinary account also.
For this example, the solution is to either escape the '?' special character (by replacing it with '%3F'):
Or to fully escape all special characters in the URL:
Similarly, if the remote server returns an image in all cases, but URL parameter values can change or modify the image that is returned, you may see that you don't get the expected image in the response. Escaping special characters in the URL so that they're sent to the remote server can also resolve such issues.
Other remote errors
Other URLs that appear OK may receive an error from the remote server. Where possible Cloudinary will return the details of that error in our response.
For example, if you request a URL that does not return an image to Cloudinary, we'll mention that in the response, such as this example where the URL fetched returned a HTML webpage, not an image asset:
Comments
0 comments
Please sign in to leave a comment.