How to create API request?

How can i send image file to API?

I want to use customvision.ai API.

1 Like

Use the Web Component.

Set URL as Web URL you Headers should look like this:

blocks (12)

And then use Post or Put File to upload the Image. Make sure you set the whole Image Path.

I can’t send my image file to API.


Test it with „do it“ if it the full path.

The API needs the full Path from you Phone.

What is your android version?

I sent it with full path. but I am getting an interesting error.
Error:1104

[I can use the API with python without any problems.]

(https://gist.githubusercontent.com/bitchwhocodes/2b0197a8c7ef261eaf503fef2fd60f0e/raw/18e1c94ee02478e2d8a6b138d6deee7af35aba71/customvis.py)


Some API I tested can’t do it to on Kodular. I can’t say why it isn’t working in some Cases.

Did you tried to use the ASD Folder?

There are examples made for API 2.0. My method of sending the image must be wrong.

I can do it in 4 lines with python. But I couldn’t do it with blocks. please help. How can I send a file to the API.

import requests, json
url="https://southcentralus.api.cognitive.microsoft.com/customvision/v3.0/Prediction/d96305a9-8d18-4ac3-8f37-a5e493ce6243/classify/iterations/Iteration1/image"
headers={'content-type':'application/octet-stream','Prediction-Key':'06d4a646232c4091884e1e98cd4a253b'}
r =requests.post(url,data=open("test.jpg","rb"),headers=headers)
print(r.content)

ML2 (1).aia (2.8 KB)

Is there any Documentation for your API?

I made ASD Folder.
API error message: BadRequestImageStream


We can help you without API Documentation.

@Ded_Sec_00 Thank you for your interest in the subject.

Microsoft Custom Vision API Documentation:

i think, this API need image in Binary content. but I don’t know how to convert it.

@Taifun

my Dropbox example also uses Content-Type octet-stream and works fine with an image
https://puravidaapps.com/dropbox.php

are you able to display the image in an image component?
make sure the path to the image is correct… try a relative path, for example /DCIM/Camera/... or a full path, for example file:///storage/emulated/0/DCIM/Camera/... (note the 3 slashes…)

Taifun

yes, i am able to display the image in an image component.
When I add “file://” prefix it gives error 1104.
BadRequestImagStream throws error when “file://” is not prefixed.

I’ve been trying for 1 week. please help me.