-1
보편적 Windows 응용 프로그램의 매개 변수와 함께 JSON 값을 게시는 범용 C#을
예 :
후 http://sampleurl?param=1¶m2=1 JSON 본문 : [{ " 키 ":"값 ","키 2 ":"값 2 "}]
보편적 Windows 응용 프로그램의 매개 변수와 함께 JSON 값을 게시는 범용 C#을
예 :
후 http://sampleurl?param=1¶m2=1 JSON 본문 : [{ " 키 ":"값 ","키 2 ":"값 2 "}]
우리는 사전과 같은 매개 변수를 생성하고 formcontent로 게시 할 수 있습니다
public static async Task<string> postdataAsync(Uri posturl, Dictionary<string, string> pairs)
{
string response = "";
try
{
var filter = new HttpBaseProtocolFilter();
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Expired);
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);
HttpClient httpClient = new HttpClient(filter);
Windows.Web.Http.HttpFormUrlEncodedContent formContent = new Windows.Web.Http.HttpFormUrlEncodedContent(pairs);
HttpResponseMessage httpresponse = await httpClient.PostAsync(posturl, formContent);
response = await httpresponse.Content.ReadAsStringAsync();
}
catch
{
return null;
}
return response;
}
무엇이 문제입니까? HttpClient를 사용하거나 URI를 작성하거나 JSON을 작성 하시겠습니까? –
다른 사람들이 선호하도록 답변을 upvote하십시오. –