POST image cURL with header

Hello, I’m trying to send a photo file to an api. I’ve tried several ways, including the web post file block.
Researching, I saw that a lot of people used the K104 Terminal extension, so let this be my path too, but I don’t have any results from the server.
I must run:

curl --location --request POST 'https://.../user/photo' \
--header 'X-Authorization: key' \
--form '[email protected]"/path/to/file"'

This is my block

I tried with this too
blocks (1)

Is it possible to do this in kodular?
Is the K104 extension the best solution for me?

You could try using Curl-to-Blocks by @Jerin_Jacob or Curl-to-Blocks - Convert Curl Request to Blocks by @HritikR


Thanks for the suggestion, but these sites don’t show how to upload the photo.
I had used this method before, but the server does not receive the photo.
PS. The server is working perfectly

And what is the API return?

With this blocks, nothing:

With this, not received the file:

Could you post a link to the api documentation ?

1 Like

I don’t have the documentation link, but it’s working perfectly as I tested it with postman. Even this line was provided by postman.

curl --location --request POST 'https://.../user/photo' \
--header 'X-Authorization: key' \
--form '[email protected]"/path/to/file"'

The server responds 200 in case of success or 400 in case of an error. If it’s a server error, it responds 500.
The submission is done with this header and the body in form-data with the attribute file.

In this app that I’m developing, it already consumes several api`s from this endpoint, only this photo upload that I can’t do through kodular.

Global foto is filled ?

1 Like

It is important to understand if the api requires multi-part form data. If it does, it is unlikely you can use the web component to upload the file. You may be able to upload using the custom webview extension.

1 Like

Great suggestion! I will study about this component. I’m new with kodular. I think this is the way. I’ll be back here with the result.