I am trying to get a very simple c# snippet on predicting an image, but get following error (there is very little on the internet around this subject):
Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.Models.CustomVisionErrorException HResult=0x80131500 Message=Operation returned an invalid status code 'NotFound'
var predictionClient = GetPredictionClient();
predictionClient.ClassifyImageUrl(Guid.Parse("5329678e-2a6b-46cf-ac11-fbd19ce89353"), "Iteration2", new ImageUrl("https://storageinfluencer.blob.core.windows.net/social-media-images/1e8bfef3-f070-44b9-9ae4-4b0d8a31316d.jpg"));
CustomVisionPredictionClient GetPredictionClient()
{
CustomVisionPredictionClient endpoint = new CustomVisionPredictionClient()
{
ApiKey = "xxx",
Endpoint = "https://northeurope.api.cognitive.microsoft.com/customvision/v3.0/Prediction/"
};
return endpoint;
}
I got a little closer by using fiddler. EndPoint should be https://northeurope.api.cognitive.microsoft.com only even if portal says copy the other as end point. However now I get:
{"code":"BadRequest","message":"Invalid project type for operation."}
I have following POST in fiddler:
I think I finally found why you got this 404, thanks to... Intelligent Kiosk demo being open-source!
See how they pass the endpoint value in their code, here:
private const string SouthCentralUsEndpoint = "https://southcentralus.api.cognitive.microsoft.com";
As you can see, the Endpoint
field is the value of the root, not the Custom Vision Prediction API
root
So change your
Endpoint = "https://northeurope.api.cognitive.microsoft.com/customvision/v3.0/Prediction/"
to:
Endpoint = "https://northeurope.api.cognitive.microsoft.com"
And it should be fine. I made a test with WestEurope and some CustomVision projects that I already had, it is working fine.
User contributions licensed under CC BY-SA 3.0