Can't upload images with cURL

Hello, I’m struggling to upload images using the API: I’m following the same code in docs and examples, but I kee getting different errors:

  1. the cURL command in the “Use API” page returns me “ERROR 5415: Images must be uploaded as a form, not as raw image data. Please use multipart/form-data format

curl --request POST https://api.cloudflare.com/client/v4/accounts/abcdefghi/images/v1 \
--header 'Authorization: Bearer 123456789' \
--form 'url=https://www.nonsolocavallo.it/foto/pe00100f-c.jpg' \
--form 'id=pe00100f-c'

← same error as above

  1. I add to the above “**–header ‘Content-Type: multipart/form-data’ **” and I get “ERROR 5400: Bad request: multipart/form-data Content-Type has invalid syntax: lacks boundary

The only way I made it work was using Postman, which uses as content-type application/json; charset=UTF-8, but if I try it on my code, I get “ERROR 5415: Images must be uploaded as a form, not as raw image data. Please use multipart/form-data format”

Ho can I do this? I have 70K of images to upload and I struggle to upload a single one, is there any way to use the service as a dummy a non ubertech guy?
Thank you

Hi, curl should work well. Can you try this?

curl --location --request POST "https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_TAG}/images/v1" \
--header "Authorization: Bearer ${AUTH_TOKEN}" \
--form 'url="https://www.nonsolocavallo.it/foto/pe00100f-c.jpg"' \
--form 'id="pe00100f-c"'

It’s the same code I use, this is what i get

HTTP/1.1 415 Unsupported Media Type
Date: Wed, 12 Oct 2022 07:28:31 GMT
Content-Type: text/plain;charset=utf-8
Transfer-Encoding: chunked
Connection: close
CF-Ray: 758e1e805d493753-MXP
Cache-Control: no-cache
Content-Encoding: gzip
Vary: Accept-Encoding
CF-Cache-Status: DYNAMIC
cf-images: err=5415
x-content-type-options: nosniff
x-envoy-upstream-service-time: 5
Server: cloudflare

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

This topic was automatically closed after 15 days. New replies are no longer allowed.