![](/img/trans.png)
[英]How to convert numeric value in English to Marathi numeric value in C#?
[英]How to post a numeric value in c#
我正在嘗試使用HTTPclient發布到第三方api並獲得響應。 我可以發布到api,但是我遇到的問題是api需要programid為數字。 每當我嘗試使用此代碼發布時,它都會將其扔回,告訴我將programid設為數字。
我不知道如何通過ac#/。net發送數字
using (var client = new HttpClient())
{
var values = new Dictionary<string, string>
{
{ "accesstoken", authtoken },
{ "programid", programid},
{ "email", person.Email },
{ "thirdparty1", person.ID.ToString() }
};
var content = new FormUrlEncodedContent(values);
var response = client.PostAsync("url", content);
var responseString = response.Result.Content.ReadAsStringAsync();
}
也許是WebClient?
using (var client = new WebClient())
{
var values = new Dictionary<string, string>
{
{ "accesstoken", authtoken },
{ "programid", programid.ToString()},
{ "email", person.Email },
{ "thirdparty1", person.ID.ToString() }
};
var param = string.Join("&", values.Select(x => x.Key + "=" + x.Value).ToArray());
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string HtmlResult = client.UploadString(URI, "POST", param);
}
只要確保您沒有傳遞任何有趣的網址路由字符,例如? 要么 &
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.