Images API Upload via URL

HI! can somebody help me to sort this out? please?
This is my first time using Cloudflare. I need to upload images using URLs.
like there
https://developers.cloudflare.com/images/cloudflare-images/upload-images/upload-via-url/
I read the docs and tried to make a request. But I keep getting an error

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

there is my code

const formdata = new FormData();
formdata.append(‘url’, “https://filepath”, “image.jpg”)

await axios({
url: https://api.cloudflare.com/client/v4/accounts/${accountId}/images/v1,
method: “POST”,
headers: {
Authorization: Bearer ${apiToken}',
},
body: formdata
});

tell me what i’m doing wrong

Make sure you’re adding the right Content-Type header - the examples use curl and it wouldn’t surprise me if it just implicitly added the headers when you use --form

Content-Type: multipart/form-data

1 Like

thank you, everything worked out! You saved my day!

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.