Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (5.8k points)

So I am currently working with an Azure Machine Learning experiment. I was able to create a model and post it as a web service. I was also able to get the response using the sample request/response code in C# provided in the API documentation that was generated when I created the web service.

My problem is, the response provided by the web service contains many information (a long string of info) including the Prediction Score which is the only thing I need for my C# application. The only thing that comes in mind is to use string manipulation methods in order to extract the info I want. But I think there's a better way than that. I am new to HTTP Request/Response, so please elaborate answers and explanations about it.

Here's my code:

HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest);

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);

}

1 Answer

0 votes
by (9.6k points)

Before web service output, add Select Columns in dataset to add the columns you want to test out and predict results from. 

For example:

 

Browse Categories

...