From the course: Machine Learning in Mobile Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Client tie to Visual Recognition response

Client tie to Visual Recognition response - Xamarin Tutorial

From the course: Machine Learning in Mobile Applications

Start my 1-month free trial

Client tie to Visual Recognition response

- [Instructor] Now we're ready to call the web service. So we'll do var response, and that's going to be equal to await 'cause that's an asynchronous call, the client and we'll call PostASync. We're going to pass in our URL and the request content. And if we get a success status code back, we'll continue on, otherwise we're just going to hop out of this method. And if it is successful, we need to pull up the response strength, so we're going to create a variable called contentString. That's going to be equal to await_response dot content ReadAStringAsync. And that will pull out a JSON object, or at least a string that represents a JSON object. Now we could create classes and de-serialize a string that way, but we can also do this inline using anonymous object. This is a very complex JSON object with several internal arrays, but it's just simple enough where we should be able to do it inline. So I'll go var definition equals new, and this is going to be a JSON object with a property…

Contents