How to make an HTTP POST web request

后端 未结 14 2746
有刺的猬
有刺的猬 2020-11-21 04:31

Canonical
How can I make an HTTP request and send some data using the POST method?

14条回答
  •  隐瞒了意图╮
    2020-11-21 05:00

    If you like a fluent API you can use Tiny.RestClient. It's available at NuGet.

    var client = new TinyRestClient(new HttpClient(), "http://MyAPI.com/api");
    // POST
    var city = new City() { Name = "Paris", Country = "France" };
    // With content
    var response = await client.PostRequest("City", city)
                               .ExecuteAsync();
    

提交回复
热议问题