Images API

Hi,
Wanted to give some feedback on the Images API.
However, it turns out that the feedback-widget is not working /-:
Looking in network tab, it tries to post to https://feedback.developers.cloudflare.com/api/new but gets 404
While you’re at this widget, your text should be persisted in session-storage until submitted. Right now if you start typing and then do anything else like navigating, you have to retype everything.

So here is my feedback:
The docs are not thorough enough.
E.g it is not clear if the body has to be encoded as application/json or url-encoded;
There is no api-reference that explains all properties, just examples that I have to figure-out;
The customId doc is not clear;

OK, it turns out that there’s Cloudflare docs here: https://developers.cloudflare.com/images/cloudflare-images/upload-images/direct-creator-upload/
and api reference here: Cloudflare API v4 Documentation
Not sure why it’s separated like that, it’s confusing.
The second link contains better documentation organized as api-reference with explanation on each property.

Now I was facing another issue with the API. When calling POST accounts/:account_identifier/images/v2/direct_upload with JSON body and Content-Type:application/json header, as the example shows, I get back an error

ERROR 5415: Images must be uploaded as a form, not as raw image data. Please use multipart/form-data format

This error doesn’t make a lot of sense in this context, because this is not an upload endpoint. It just supposed to give me an upload URL.

I tried the same request as form-data encoded and it works. So 3 issues here:

  1. The docs show that you can use application/json body, but you can’t
  2. The error message is confusing because it talks about image upload
  3. It would be nice if this would work as standard json api

Hey, this should be fixed now! Sorry about that!

3 Likes

We just ran into this issue with image uploads today and had to change our request to add a "Content-Type": "multipart/form-data", header and an empty piece of formdata to our request body. Not sure whats going on, this endpoint use to work for us then it broke today.

1 Like