Sending Images to an API

I am trying to upload an image.jpg to an API using the post file block.
This is my code

(the image component was just to test if the file is at that path or not)

But this is the error it gives.

this is the sample code the API docs have provided


What could be the issue and how can I fix it?
Foodvisor Vision -> API docs if you wanna take a closer look
Thanks for reading : D

In postfile try:

/food.jpg

If not try full or absolute path to file

Now it is giving me a new error which basically is saying that the given image is of wrong type. But in the documentation it is saying I can send it a .jpg

the new error comes up when i use the absolute path to the file (since its the only one that proceeds to the next step basically)

API docs require a sign in....

uhh

Foodvisor Vision.txt (371.2 KB)
convert this to HTML and this should work I am pretty sure (I cant send HTML here)

Not really....

Does it show an example curl command for uploading a file ?

It is also possible that the server is expecting a browser, and you may need to include a user-agent in the headers

nope no example curl command.

The sample code i provided in the post is the only one

@TIMAI2 nvm those werent the api docs, Foodvisor Vision these are the API docs

The /analysis endpoint expects your data as multipart/form-data, which is not possible using the web component

Taifun

oh, any workaround for it?

You could try with the webviewer, using the webviewextra extension to allow you to pick files from your shared directories. Could you then use a upload html facility provided by FoodVision? (Alternatively write your own html page and host somewhere - perhaps locally on the device - in the app - if only html/javascript)

oh, so like use that snippet in my own file hosted in the assets folder right? and then get the file data from there? where would the response be generated then

In your web page (you can capture this using the webviewstring)

Ok so i am doing something similar now.
index.txt (489 Bytes)
Here is the website I have created till now. Now what I wanna do is get the analyzed image text and send it back to the app. How can I achieve this?

Upload the image
I think this is {{ analyzedImage.category.name.replace(/_/gi, ' ') }} - {{
probabilityText }} .
<- upload an image here

Nutrition profile of the average {{
analyzedImage.category.name.replace(/_/gi, ' ') }}
{{ nutrition.calories }} calories

{{ nutrition.fat }}{{ analyzedImage.nutrition.fat.unit }} fat
{{ nutrition.protein }}{{ analyzedImage.nutrition.protein.unit }} protein
{{ nutrition.carbs }}{{ analyzedImage.nutrition.carbs.unit }} carbs

Not sure what I am looking at, doesn't look like a web page to me...

what do you mean by that? like its not working or something else?
I should also clarify that this is another API called spoonacular.
spoonacular recipe and food API -> docs for this

the RequestHeaders only accept list-sublist