如何在.net中模拟post方式提交json数据
1个回答
展开全部
nuget安装Microsoft.Net.Http
HttpClient client = new HttpClient();
string postJson = JsonConvert.SerializeObject(object);
StringContent content = new StringContent(postJson, Encoding.UTF8, "application/json");
client.Timeout = new TimeSpan(0, 0, 15);
HttpResponseMessage httpResponse = await client.PostAsync(url, content);
byte[] urlContents = await httpResponse.Content.ReadAsByteArrayAsync();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询