I have created the experiment in Microsoft Azure ML and deployed as Web service and it creates the URL & API key.
But I need to pass the inputs (Country, SSN) from Visual Studio 2015 ASP.NET to get the output from Azure ML experiment which I have created
So I have created the web form in Visual Studio 2015 ASP .Net with inputs are 'Country' and 'SSN' and sending the request from ASP .NET using the created URL, API key and inputs to get the response from Azure ML.
--Sending the request from ASP .NET to Azure ML
'HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest).ConfigureAwait(false);'
But I am facing the below error when getting the response from Azure ML.
{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent,
Headers:{ x-ms-request-id: cf719cd0-a627-4b69-8b11-77a7e85ee7a3 Date: Thu, 24 Sep 2015 18:57:50 GMT Server: Microsoft-HTTPAPI/2.0 Content-Length: 194 Content-Type: application/json; charset=utf-8}}
Please find the Sample Code below:
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));
Console.WriteLine(response.Headers.ToString());
string responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseContent);
}
}
}
Please help me to provide the solution to fix this issue.