Azure 未找到Microsoft Face API 1.0错误资源

Azure 未找到Microsoft Face API 1.0错误资源,azure,microsoft-cognitive,Azure,Microsoft Cognitive,我正在与Microsoft Azure认知服务公司合作一个人脸识别项目。不太清楚为什么我不能纠正我自己的JSON格式错误的语法,我以为我在6个月前就解决了这个问题。我想创建一个组名,所以我调用了“Person group API”,每次我使用MS示例时,我的代码中都会出现错误,但是在API测试控制台中没有问题,以下是我从MS站点借用的代码示例: { "error": { "code": "ResourceNotFound", "message": "The requested resource

我正在与Microsoft Azure认知服务公司合作一个人脸识别项目。不太清楚为什么我不能纠正我自己的JSON格式错误的语法,我以为我在6个月前就解决了这个问题。我想创建一个组名,所以我调用了“Person group API”,每次我使用MS示例时,我的代码中都会出现错误,但是在API测试控制台中没有问题,以下是我从MS站点借用的代码示例:

 { "error": { "code": "ResourceNotFound", "message": "The requested resource was not found." } }
以及在控制台模式下运行的代码:

static async void CreateGroup()
        {
            string key1 = "YourKey"; 
             // azure the one should work 
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
           client.DefaultRequestHeaders.Add
           ("Ocp-Apim-Subscription-Key", key1);

        var uri = "https://westus.api.cognitive.microsoft.com/face/v1.0/
        persongroups/{personGroupId}?" + queryString;

        HttpResponseMessage response;

        // Request body
        string groupname = "myfriends";

        string body = "{\"name\":\"" + groupname + ","+ "\"}";
        // Request body
        using (var content = new StringContent
        (body, Encoding.UTF8, "application/json"))
        {

            await client.PostAsync(uri, content)
                .ContinueWith(async responseTask =>
                {
                    var responseBody = await responseTask.Result
                    .Content.ReadAsStringAsync();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Response: {0}", responseBody);
                    Console.WriteLine("");

                    Console.WriteLine("Group Created.... ");
                    Console.WriteLine("Hit ENTER to exit...");
                    Console.ReadKey();
                });

            response = await client.PutAsync(uri, content);
            Console.WriteLine("what is this {0}", response.ToString());
            Console.ReadKey();

        }// end of using statement 


    }// end of CreateGroup
    #endregion

我猜是在这里,但我认为我的JSON又是错误的,我只是不知道这次我又做错了什么。根据该站点,我需要发送给ms的字段名是
'name':'userData'
是可选的。

您的请求url必须指定一个组ID来代替您的
{personGroupId}
。根据,组ID必须为:

用户提供的personGroupId作为字符串。有效字符包括 数字、小写英文字母、'-'和''.'。最大值 personGroupId的长度为64

此外,http动词需要PUT,而您已经发出了一个
client.PostAsync
请求。因此,您需要将其更改为
client.PutAsync


Microsoft为C#提供了一个客户端库,您可以在其中找到工作的C#代码。

在uri中添加“/detect”后,遇到了类似的问题,该问题已得到修复。 见下文

var uri = "https://westus.api.cognitive.microsoft.com/face/v1.0/detect

还要确保订阅密钥有效。

在python中,这对我来说很有效

端点=“”