C# 编程LUIS predict API返回400错误

C# 编程LUIS predict API返回400错误,c#,microsoft-cognitive,azure-language-understanding,C#,Microsoft Cognitive,Azure Language Understanding,我测试时,预测API在一周前工作,但今天早上(2016年12月2日)突然停止工作,出现以下错误: { "error": { "code": "BadArgument", "message": "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" } } { "error": { "code":

我测试时,预测API在一周前工作,但今天早上(2016年12月2日)突然停止工作,出现以下错误:

{
  "error": {
    "code": "BadArgument",
    "message": "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
  }
}
{
  "error": {
    "code": "BadArgument",
    "message": "Value cannot be null. Parameter name: Array of utterances cannot be null"
  }
}
此调用的API引用为

这是我正在使用的示例代码:

static void Main()
{
    MakeRequest();
}

static async void MakeRequest()
{
    var client = new HttpClient();
    var queryString = HttpUtility.ParseQueryString(string.Empty);
    client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "*****");
    var uri = "https://api.projectoxford.ai/luis/v1.0/prog/apps/******/predict?" + queryString;
    HttpResponseMessage response;
    byte[] byteData = Encoding.UTF8.GetBytes("test.");
    using (var content = new ByteArrayContent(byteData))
    {
        response = await client.PostAsync(uri, content);
    }
}

这里有人有同样的问题吗?

我刚刚尝试使用API,它对我有效。如果我使用“test”发出请求,就像在示例代码中一样,我会得到以下错误:

{
  "error": {
    "code": "BadArgument",
    "message": "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
  }
}
{
  "error": {
    "code": "BadArgument",
    "message": "Value cannot be null. Parameter name: Array of utterances cannot be null"
  }
}
但是,当我将其更改为json数组时,如:

byte[] byteData = Encoding.UTF8.GetBytes("[ 'test.' ]");
它工作得很好,我得到了预期的预测


我建议您更新这行代码,看看会发生什么。

我不确定问题出在哪里,但我只是删除了应用程序并重新创建,问题就消失了


希望它能帮助路过的人。

谢谢,我刚刚尝试过,但仍然得到相同的错误,我的错误是“必须是非负的,并且小于集合的大小。参数名称:index”。not“参数名称:语句数组不能为空”。有什么想法吗?我知道;我不能完全用你的代码重现那个错误。仔细检查应用程序和subs键,但是如果其中任何一个错误,我怀疑你不会有这个错误