Forum Documentation Showcase Pricing Learn more

Trying to use api to upload file

Hi,

I’m trying to upload a file with the bubble API.
I’ve a data Type called ‘Document’ with a field ‘document_file’ which is a field of type file.

I’m doing a post request with postman on the data type api and giving a json object as a value for the key ‘document_file’.

Here is my json object :

{"filename":"pixel.png", "contents":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==","private":false}

But each time the response is

"body": { "status": "INVALID_DATA", "message": "Invalid data for field document_file: not a valid url or object" }

Am I missing something ? please help. Also I can’t pass an URL so I need to use this method.

Many thanks

Hello @julesha,

Take a look at the attached screenshot, please:

Let me know if you have any questions, please.

Cheers!

1 Like

Hi @julesha,

This has also been discussed in this thread.

Basically, the JSON object representing the file must itself be the “value” of the “key” defined in the endpoint. As such, the name of the key must be included in your JSON with the file details as the object, as @lottemint.md points out.

2 Likes

works like a charm !

1 Like