【发布时间】:2017-03-22 05:16:32
【问题描述】:
我正在编写 UWP 应用程序。
我需要向服务器发送带有 json 的 POST 请求
这是我下载 JSON 并写入值的代码:
public async void AllOrders_down()
{
string url = "http://api.simplegames.com.ua/index.php/?wc_orders=all_orders";
var json = await FetchAsync(url);
List<RootObject> rootObjectData = JsonConvert.DeserializeObject<List<RootObject>>(json);
OrdersList = new List<RootObject>(rootObjectData);
}
public async Task<string> FetchAsync(string url)
{
string jsonString;
using (var httpClient = new System.Net.Http.HttpClient())
{
var stream = await httpClient.GetStreamAsync(url);
StreamReader reader = new StreamReader(stream);
jsonString = reader.ReadToEnd();
}
return jsonString;
}
我需要如何将带有这个 json 的 POST 请求发送到服务器?
谢谢你的帮助。
【问题讨论】:
标签: c# json visual-studio uwp