1

I am trying to use Microsoft's Custom Vision API, but am running into nothing but 404 errors. How can I use the API?

I have tried copying and pasting and modifying the prediction sections of the Python and Javascript samples, such as the one found here: https://github.com/Azure-Samples/cognitive-services-node-sdk-samples/blob/master/Samples/customvision/customVisionImgClassify.js

Copying and pasting the prediction URL into my browser from the Perfomance page of Custom Vision, which is:

https://japaneast.api.cognitive.microsoft.com/customvision/v3.0/Prediction/999999999999999/classify/iterations/Iteration4/image

, yields the same 404 error:

{ "error":{ "statusCode": 404, "message": "Resource not found" }}

The closest I have gotten to successfully accessing the API is through an Azure Logic App, which uses an old version of Custom Vision:

/customvision/v1.0/Prediction/99999999999999999/image

This access method yields an "Unauthorized" error instead of a 404.

I tried modifying the JSON in the Azure Logic App to use the newer version of Custom Vision but am back to getting 404 errors. See below for the JSON (I replaced the keys and IDs with 9s):

"Predict_tags_from_image": {
                "inputs": {
                    "body": "@triggerBody()",
                    "headers": {
                        "Content-Type": "application/octet-stream",
                        "Prediction-Key": "9999999999999"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['cognitiveservicescustomvision_1']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "https://japaneast.api.cognitive.microsoft.com/customvision/v3.0/Prediction/9999999999999/classify/iterations/Iteration4/image"
                },
                "runAfter": {
                    "Create_file": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }

Thank you in advance for any help with this!

Tyson
  • 592
  • 4
  • 13
  • 1
    The Customvision_AI prediction API will return a 404 if you send a GET request instead of a POST request. Hope this helps some future visitor. – Brady Aug 27 '21 at 15:13

1 Answers1

1

I tried creating a request with the url you provided and couldn't reproduce the 404 issue. It's showing 401, as I do not have your project id or prediction key. But when I try with my own project and prediction key, everything works and it's returning 200 OK.

Screenshot1

Screenshot2

Could you please confirm the prediction url and prediction key header and try again?

Michael Ma
  • 36
  • 3
  • Thank you for the response and screenshot! I see that you are using PostMan, so I downloaded PostMan and gave it a try that way. Everything worked great with PostMan. I was able to send an image to the server and get a prediction back. It was very easy and I had no problems. Thanks again for that! Do you know why doing the same thing via my browser's address bar gives me a 404 (Chrome)? Postman gives me the expected 401 Unauthorized. Perhaps knowing why my browser gives a different result for the same action will give me a hint as to how to get Azure Logic App or my own programs working. – Tyson Jun 13 '19 at 02:06
  • 1
    Based on [documentation](https://southcentralus.dev.cognitive.microsoft.com/docs/services/Custom_Vision_Prediction_3.0/operations/5c82db60bf6a2b11a8247c15), the prediction call is a POST call. When you make request via browser's address bar it makes a GET call, and thus it's returning 404. – Michael Ma Jun 13 '19 at 16:53
  • Ah, I understand now. Thank you very much! – Tyson Jun 13 '19 at 23:55