Fix the 'Upload preset not found' error in Cloudinary
By Flavio Copes
Fix the Cloudinary Upload preset not found error, a 400 Bad Request, by creating an upload preset in the dashboard and passing its name as upload_preset.
The Cloudinary “Upload preset not found” error means the upload_preset value you’re sending doesn’t match any preset in your account. The fix is creating one in the dashboard (or fixing a typo in the name) and passing its exact name in the upload request.
Here’s how I ran into it, and how I fixed it.
I was doing a test project that used Cloudinary as the image storage.
I ran into this issue when I tried uploading the image. I received a 400 Bad Request with this JSON message:
{"error":{"message":"Upload preset not found"}}
Turned out I didn’t set up an Upload Preset.
What is an upload preset?
An upload preset is a named set of upload options stored on Cloudinary’s side: which folder to store files in, what transformations to apply, allowed formats, and so on.
When you upload from the browser without signing the request, Cloudinary requires a preset. Your API secret can’t live in client-side code, so the preset acts as the pre-approved configuration for those uploads.
How to create one
You need to go in the Settings in your Cloudinary Dashboard, in the Upload tab you click “Add upload preset”, and you add one.
Then you use that preset name in your Cloudinary upload code.
For example I had a canvas object from an HTML canvas I wrote to, and this was the code to upload it to Cloudinary as an image:
const base64Image = canvas.toDataURL()
const formData = new FormData()
formData.append('file', base64Image)
formData.append('upload_preset', '***THE_PRESET_NAME***')
fetch(`https://api.cloudinary.com/v1_1/***YOUR_CLOUD_NAME***/image/upload`, {
method: 'POST',
body: formData,
})
Tip: while testing you might choose to add an unsigned upload preset, as it simplifies the code.
Still getting the error?
If you created the preset and still see it, check these:
The preset name must match exactly. It’s case sensitive, and a copy-paste with a trailing space is enough to break it.
The preset must be in the right account. If you have multiple Cloudinary accounts or environments, the preset lives in one of them, and the cloud name in your upload URL must belong to that same account.
Also check the preset’s signing mode. If it’s set to “Signed” and you upload without a signature, Cloudinary rejects the request with a different message, about the preset needing to be whitelisted for unsigned uploads. Switch the preset to “Unsigned” for browser-side uploads like the one above.
Related posts about services: