Как решить проблему с кодом состояния 400: плохой запрос в Visual Studio ASP .Сеть при подключении к Microsoft Azure ML
Я создал эксперимент в Microsoft Azure ML и развернул его как веб-службу, и он создает URL-адрес и ключ API.
Но мне нужно передать входные данные (Страна, SSN) из Visual Studio 2015 ASP.NET чтобы получить результат эксперимента Azure ML, который я создал
Поэтому я создал веб-форму в Visual Studio 2015 ASP .Net с входов 'страна' и 'ССН' и посылает запрос с АСП .Net с помощью созданного URL-адрес API-ключ и входы, чтобы получить ответ от Azure мл.
-- Отправка запроса из ASP .NET в Azure ML
'HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest).ConfigureAwait(false);'
Но я столкнулся с приведенной ниже ошибкой при получении ответа от Azure ML.
{Состояния: 400, ReasonPhrase: 'Неверный Запрос', Версия: 1.1, Содержание: Система.Нет.Протоколу HTTP.StreamContent,
Заголовки:{ х-МС-идентификатор запроса: cf719cd0-a627-4b69-8b11 вы-77a7e85ee7a3 дата: Чт, 24 сен 2015 18:57:50 мск сервер: компания Microsoft-HTTPAPI/2.0 контент-длина: 194 тип контента: приложение/JSON; кодировка=кодировка UTF-8}}
Пожалуйста, найдите пример кода ниже:
using (var client = new HttpClient()) { var scoreRequest = new { Inputs = new Dictionary<string,>() { { "input1", new StringTable() { ColumnNames = new string[] {"Country", "SSN"}, Values = new string[,] { { strCountry, SSN} } } }, }, GlobalParameters = new Dictionary<string,>() { } }; const string apiKey = "4mgUBPxzQIuFPjR7ACHwm3epGRtlznVF9svU0zbshMTQl9l6M2/MpT+FKhOmytkj8Dhv9QuwWHxIJOis9QsvHg=="; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); client.BaseAddress = new Uri("https://ussouthcentral.services.azureml.net/workspaces/cba5f97476104d3697ad920b1e7a136d/services/2694f6eafd7f4a74937eb9ddb85bcc90/score"); HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest).ConfigureAwait(false); if (response.IsSuccessStatusCode) { string result = await response.Content.ReadAsStringAsync(); Console.WriteLine("Result: {0}", result); } else { Console.WriteLine(string.Format("The request failed with status code: {0}", response.StatusCode)); // Print the headers - they include the requert ID and the timestamp, which are useful for debugging the failure Console.WriteLine(response.Headers.ToString()); string responseContent = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseContent); } } }
Пожалуйста, помогите мне найти решение для устранения этой проблемы.