更新时间:2022-11-09 09:32:37
您混合了多种发送数据的方式:
数据
字符串包含application / x-www-form-urlencoded
data:
You're mixing up multiple ways of sending data:
- The
data
string containsapplication/x-www-form-urlencoded
data:
?username=...&type=text
JsonConvert.SerializeObject
将该字符串转换为JSON:
JsonConvert.SerializeObject
to convert that string to JSON:
"?username=...&type=text"
PostAsJsonAsync
,它将再次对数据进行JSON编码:
"\"?username=...&type=text\""
using (var client = new HttpClient())
{
response = await client.PostAsJsonAsync(BaseUrl, new
{
username,
password,
api_key = apikey,
from,
to,
text,
type = "text"
});
}