Form Post where body is raw binary, possible?

I have an endpoint that takes an image’s binary as the form post body, then returns JSON describing the image. I know it works, as it’s in production and I can call via postman. But in postman, I can specify a file for the body. In bubble I only have raw as option. I cannot get it to send valid binary. I tied raw with * and then in the test app I specify an input that takes a file (the image) and then sends it but doesn’t work. The API takes binary as the form data, so no flexibility. I need to upload image binary and get back json. I’ve searched but cant find an example.

What did you set in API connector?

If that field Body (JSON object expects a JSON) then the FileUploader… is not going to work. You’d need to format it as a value pair like the API would expect eg. {’‘image’’: “FileUploader…” }. You’ll need to look at the API documentation to decide how it should be set up. As Jici mentioned, seeing the API connector setup can also be very helpful.


I have used the toolbox run javascript element to send binary or blobs via API request as I have not been able to figure out how to send binary via bubbles api connector (as binary is not a valid type in bubble and won’t work if you just store it as a text). I think your best bet would be to build a plugin that takes the image, converts it to binary and executes the api request all within the plugin

If you are just sending an image that is stored in bubbles database (which is what I assume your sending based on that screenshot) then you are just sending a url as the json, not binary

In Bubble, you send the file using a parameters checked to file. This is only available if you select form-data as the type of the body. You will provide a link to the file and Bubble will send the file.

Still doesn’t make sense. If I am sending raw data, not JSON, then how does raw data that is binary make it to the API I am calling. API takes raw image data as binary and then return json data describing. This should be simple, but it’s not. I’m obviously missing something in the POST content, as simply pasting the bas64 encoded doesn’t work. pasting binary doesn’t work. But I know the api works as it’s tested in postman. Surely it can’t be that hard?

Not sending JSON. I’m sending binary and getting back json

Not using parameters. It’s a post where the request content is raw binary.

When calling this endpoint there are no other options other then sending a form post where the body is binary and the content type specifies what it is. There has to be some magical combination to the base64 encoded data that is pre-pended to the data? Or is this not supported by bubble? Again, I have no flexibility in the API I’m calling…I need to post BINARY as the POST’s request body and receive JSON as the response.

What you need to understand is that what you need to send is a form data. Don’t select raw, but form-data.
Add a parameters, and select the checkbox for file. Give the parameters a name and, to initialize upload a file for testing.
Bubble will send the binary content to the API

Also, the best is always to provide API doc url

This is also possible that the API will need to send it not in form data. In this case, you need to create your own call in plugin or with JS toolbox server side script… But a plugin may be easier to handle the response

Yep I don’t think you can send binary in Bubble as bubble doesn’t provide a data type that can store binary (binary is not text).

Hence why you have to convert it to binary in a javascript and then send it from inside the javascript module.

Happy to be corrected if someone has found a way to store binary in bubble but I have made this work in javascript before

Yikes. Bubble needs to put some developers to work trying to emulate cURL and/or Postman’s capabilities IMHO. I would think I should be able to just specify file as the body and then have Bubble automagically do what needs to be done behind the scenes. Oh well, thanks for the responses.

You are missing the point. That’s all well and good if i can change the API I am calling, but I cannot. A POST can send binary data as the request body. I know what you are saying, but that is not an option, as I do not control the Endpoint. And i suppose you are right, Javascript might be the solution…but JavaScript IS coding lol.