0

Whenever var result = await endpoint.ClassifyImageAsync(myProjectID, "Iteration2", photo.GetStream()); is called an error, stating Operation returned an invalid status code 'NotFound' Xamarin forms and Azure CustomVision occurs. I have tried to follow the tutorials on Custom Visions docs and I believe myProjectID, endpoint and prediction key are correct. I am using the using the Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction; package for my code.

Things to note:

When I run my endpoint link in a browser it gives an error 404(has very similar error results to this error, could be correlated?)

I am storing keys and endpoint url in strings not environment variables.

namespace CustomVisionTesting
{
    // Learn more about making custom code visible in the Xamarin.Forms previewer
    // by visiting https://aka.ms/xamarinforms-previewer
    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {



        string predictionKey = "2l013000c2355b718ng04aca6a540d5d";

        string ENDPOINT = "https://realcustomvisionservice.cognitiveservices.azure.com/customvision/v3.0/Prediction/7bfir91a-m9vj-mp3k-bk34-jfkbi4jcjs24/detect/iterations/Iteration2/image";

        public MainPage()
        {
            InitializeComponent();
        }

        async void Button_Clicked(System.Object sender, System.EventArgs e)
        {

            var options = new StoreCameraMediaOptions();



            var photo = await CrossMedia.Current.TakePhotoAsync(options);

            CustomVisionPredictionClient endpoint = new CustomVisionPredictionClient()
            {
                ApiKey = predictionKey,
                Endpoint = ENDPOINT


            };








            Guid myProjectID = Guid.Parse("7bfir91a-m9vj-mp3k-bk34-jfkbi4jcjs24");

            var result = await endpoint.ClassifyImageAsync(myProjectID, "Iteration2", photo.GetStream());


        }




    }

Images of the error and how I got my keys, keys have been changed

1 Answers1

1

Your endpoint value is incorrect: as you are using the package, you have to pass the "root" endpoint which is valid for all Custom vision prediction operations. The endpoint that you provided is the full endpoint to do a "Detect" operation.

In you case, replace the following

string ENDPOINT = "https://realcustomvisionservice.cognitiveservices.azure.com/customvision/v3.0/Prediction/7bfir91a-m9vj-mp3k-bk34-jfkbi4jcjs24/detect/iterations/Iteration2/image";

by

string ENDPOINT = "https://realcustomvisionservice.cognitiveservices.azure.com";

It is the package that you are using which is in charge to append additional url details

Nicolas R
  • 13,812
  • 2
  • 28
  • 57