How to post image/file with api?

Hi, can someone advise on how to use the API of the server connect to post image files from for example postman?

I need to use the api to create posts. It works when only posting the post text, but I can’t make the image upload work.

The external source that sends the post request returns the image file with Base64 format it says

Are you talking about the API Action step of the server connect?

API Action doesn’t support file uploads, you can use Sid’s extension

No idea what gibberish you wrote here :sweat_smile: The way you worded it makes it unclear the destination of the post request and who replies the Base64 image (if it’s your Wappler app or an external API)

Hi! Haha yes sorry it seems that I couldn’t explain it well.

I have an API, created with Wappler, that I should send two POST values to

  • text (string)
  • image (file) (binary?)

I’m using the API to create posts/content, which I’m also using in my web app created with Wappler + server connect form + file upload

I need to create posts by using this API endpoint from draftbit (mobile app builder)

Draftbit’s file upload mentions that the data is in base64 format, which I now learned that it’s binary encoding.

I added the base64 format variable to the body with the POST request, but it didn’t work. I couldn’t get any useful debugging messages so I‘m not understanding what’s wrong.

What does the “file” variable in the server connect API expect as value?

Are you talking about Sid’s extension? It’s the file path in the following format:


If you’re not talking about Sid’s extension, I’m afraid I’m not the best person to answer this - I never handled file uploads in Wappler. Put a Set Value step with the expression $_POST.file or whatever to see what kind it is

So it converts an image file (binary) to text (string)

Your problem - I guess - is converting an image file into a Base64 string representation. Is that it? You could build a custom formatter (or module) that reads a file and converts it to Base64

Here I’m talking about the variable that you create in the Post values in the server connect api file.

Ok thank you, will try to play around more with this. When checking the api action in browser inspect (when using the api trough Wappler), the payload of the “image” value mentions binary, and since the draftbit one mentions base64 I’m sure that it should work somehow, will try to investigate further

You could try the Base64 encoder formatter already built-in into Wappler, check the expression builder. Hope it works on such a “binary” variable

No problem!

1 Like