调试WebApi的一些方法

1、Get方法时,直接用浏览器访问

2、Postman

3、用HttpClient调用

privatevoid GetData()
{
    using (HttpClient client = new HttpClient())
    {
        client.BaseAddress = new Uri("ipaddress");
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json")); try { HttpResponseMessage response = client.GetAsync("testapi/getdata?id=0").Result; } catch { } } }

猜你喜欢

转载自www.cnblogs.com/dayang12525/p/9836157.html