Use nested objects along with files in query form-data

My POST backend endpoint accepts multipart/form-data with nested object and 2 files. Example:

I wonder how to handle that properly in retool.

Here is my payload in query:

Query in the app:

I am using transformer for 'data':

And receive error:
create_account_query failed (3.265s):{"status":415,"message":"","type":"about:blank","title":"Unsupported Media Type","detail":"Content-Type 'application/octet-stream' is not supported.","instance":"/clients"}

I have no idea where "application/octet-stream" come from? I tried also without JSON.stringify, the same error.

Files are correct:

Can you help to figure out actual issue and recommend approaches to handle nested objects for form-data in Retool. Thanks

Hi there @Andrey_Rafalskyi,

That erro is indeed really weird.

Have you tried:

  • Using the resource directly in the app rather than a query library?
  • using RAW setting in your body insteadof FormData?
  • Hard coding each one of the fields to debug which one is the one triggering that error?
1 Like

@MiguelOrtiz I figured out we need to send content-type for nested object. Example in Postman:


In this case everything works well.

How to add content-type in Retool?

Related issue I found: Need to add content-type in each part in multi-part form data

Hi @Andrey_Rafalskyi,

If you are using a REST API query, you would specify this in the query header as such,

Let me know if that works for you!

If that doesn't work, you may need to base64 encode the two jpeg files and then use a JS query to combine the JSON data with the strings from those two files :sweat_smile:

Hi @Andrey_Rafalskyi,

Just wanted to circle back and see if you are still facing this issue.

As well as if my comment was helpful or if you needed to pass the data in differently.