【发布时间】:2020-05-02 13:58:17
【问题描述】:
我需要在帖子中将字符串值作为文本传递。
我已经尝试了以下
string content = "91237932,xy91856,0,0";
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.PostAsync(ConfigurationManager.AppSettings["AttributesApi"] + $"/api/UserProfiles/UpdateUserProfileFromIAM", new StringContent(content));
这是我必须使用的(不能按现有更改),但值为 null
[HttpPost("UpdateUserProfileFromIAM")]
public async Task<ActionResult> UpdateUserProfileFromIAM(string attributes)
{
//attributes null
}
这个 HttpClient 帖子怎么做,让它是一个简单的字符串值?
【问题讨论】:
-
取决于你在努力解决什么问题?如果它阅读结果,我已经发布了答案。如果不是,请澄清
-
尝试将其放在根类中,例如:
public class Root{public string attributes{get;set;}},并更改签名,例如:UpdateUserProfileFromIAM(Root root)
标签: c# asp.net-web-api httpclient