A pretty typical CRUD operation will result in an object having its Id set once persisted.
So if I have Post method on the controller which accepts an object (JSON
You can use ReadAsAsync<T>
.NET 4 (you can do that without continuations as well)
var resultTask = client.PostAsJsonAsync<MyObject>("http://localhost/api/service",new MyObject()).ContinueWith<HttpResponseMessage>(t => {
var response = t.Result;
var objectTask = response.Content.ReadAsAsync<MyObject>().ContinueWith<Url>(u => {
var myobject = u.Result;
//do stuff
});
});
.NET 4.5
var response = await client.PostAsJsonAsync<MyObject>("http://localhost/api/service", new MyObject());
var myobject = await response.Content.ReadAsAsync<MyObject>();