0

在通过参数化 url 从我的 Entires 发布数据时遇到问题,我不知道为什么会这样,该 URL 在发布后返回一条消息,下面是我的 URL:

http://bbs.eamobiledirectory.com/Mobile/MobileApi.aspx?Action=NewSalesReport&username=USERNAME&assID=ASSIGNID&repdetails=details&appoi_date=date

这就是我发布数据的方式:

    void OnSubmitReport(object sender, System.EventArgs e)
        {
            PostData();
        }


        public async void PostData()
        {


            string details = report_details_entry.Text;
            string date = nextappointment_entry.Text;


            var formContent = new FormUrlEncodedContent(new[]
                        {
                new KeyValuePair<string, string>("unm", USERNAME),
                new KeyValuePair<string, string >("assinID", ""+ASSIGNID),
                new KeyValuePair<string, string>("details", details),
                new KeyValuePair<string, string>("appoi_date", date)

   });

            var response = await client.PostAsync("http://bbs.eamobiledirectory.com/Mobile/MobileApi.aspx?Action=NewSalesReport",formContent);


        }

我想要的是在病房后提交条目中的数据,我在 DisplayAlert 消息中返回一条消息。

4

1 回答 1

0

直到你弄清楚为什么 FormUrlEncodedContent 不起作用(我真的很想知道它为什么不起作用)

您可以通过以下方式发布来解决您的问题:

var url = string.Format("http://bbs.eamobiledirectory.com/Mobile/MobileApi.aspx?Action=NewSalesReport&unm={0}&assignID={1}&report_details={2}&appoi_date={3}",
                USERNAME,
                ASSIGNID,
                details,
                date);

var response = await client.PostAsync(url, null);

var responseContent = await response.Content.ReadAsStringAsync();
于 2017-07-06T14:37:50.107 回答