【发布时间】:2016-12-12 07:28:08
【问题描述】:
我想在我的应用程序中向 json 服务添加一条记录。我怎样才能通过服务网址做到这一点。这是我的代码。
CustomerModel customer = new CustomerModel();
customer.Name = entryCompanyName.Text;
customer.Title = entryCompanyTitle.Text;
customer.PhoneNumber = entryTelephone.Text;
customer.FaxNumber = entryFax.Text;
customer.Email = entryEmail.Text;
customer.CityId = 6444;
string json = JsonConvert.SerializeObject(customer);
string sContentType = "application/json";
string path = "service url";
HttpClient Client = new HttpClient();
var task = Client.PostAsync(path, new StringContent(json.ToString(), Encoding.UTF8, sContentType));
我正在尝试 M. Wiśnicki 的解决方案,但我遇到了这个错误
我在添加 System.net 时没有收到错误 :( 我在哪里出错了?
【问题讨论】:
-
这段代码有什么问题?
-
找不到这些方法; GetRequestStreamAsync GetResponseAsync
标签: c# json post xamarin xamarin.forms