Why am I getting an error when trying to fetch an image from a remote URL?

When experiencing an error, you can have a look at the HTTP response header to get the error's details.

Here's an example of such an error. 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

we'll see the following HTTP response header:

X-Cld-Error:Invalid fetch URL - not properly escaped

This is returned when the URL we're trying to fetch the image from includes special characters. In this case '?'. URLs must be escaped for special characters for fetching.

In this case, the solution is to either escape the '?' special character (by replacing it with '%3F'):

http://res.cloudinary.com/demo/image/fetch/https://encrypted-tbn1.gstatic.com/images%3Fq=tbn:ANd9GcTm_o8s5J9-z2SAZ5yGfsD-fbZox4wGv1Fzlt0DIf4qrLbfgMZS5w

Or to fully escape the whole URL:

http://res.cloudinary.com/demo/image/fetch/https%3A%2F%2Fencrypted-tbn1.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcTm_o8s5J9-z2SAZ5yGfsD-fbZox4wGv1Fzlt0DIf4qrLbfgMZS5w

Have more questions? Submit a request

Comments

Powered by Zendesk