[Solved] HttpClient what and for what? [closed]


This should give you a start:

private Order SendOrderRequest(Models.OrderTest model)
{
    Uri uri = new Uri(model.BaseUrl + "order");

    HttpClient client = new HttpClient();

    client.BaseAddress = uri;

    var mediaType = new MediaTypeHeaderValue("application/json");
    var jsonFormatter = new JsonMediaTypeFormatter();

    HttpContent content = new ObjectContent<Order>(model.Order, jsonFormatter);
    HttpResponseMessage responseMessage = client.PostAsync(uri, content).Result;

    return responseMessage.Content.ReadAsAsync(typeof(Supertext.API.POCO.Order)).Result as Supertext.API.POCO.Order;
}

It just posts the order object inside the model to a Web API (and gets an order object back)

2

solved HttpClient what and for what? [closed]