标签:
https://monkeyweekend.wordpress.com/2014/10/23/how-to-send-text-json-or-files-using-httpclient-postasync/
using Windows.Web.Http;
using Windows.Data.Json;
例:
//post request
Windows.Web.Http.HttpClient oHttpClient = new Windows.Web.Http.HttpClient();
Uri uri = new Uri("https://www.abc.com/testapi");
string contentBody = "the data you want to post";
HttpRequestMessage mSent = new HttpRequestMessage(HttpMethod.Post, uri);
mSent.Content =new HttpStringContent(String.Format("{0}", contentBody), Windows.Storage.Streams.UnicodeEncoding.Utf8);
HttpResponseMessage mReceived = await oHttpClient.SendRequestAsync(mSent, HttpCompletionOption.ResponseContentRead);
//read reponse to json string
string jsonStr = await mReceived.Content.ReadAsStringAsync();
//parse json
JsonValue jsonValue = JsonValue.Parse(jsonStr);
string bruid = jsonValue.GetObject().GetNamedString("someKey");
标签:
原文地址:http://www.cnblogs.com/yibinpan/p/4551677.html