我正在尝试使用 HttpClient 发出发布请求,但似乎我的参数没有被传输,因为我收到了一个错误的请求响应,说明需要一个 client_id。有人可以向我指出我做错了什么。以下是相关代码:
var authLinkUri =
new Uri(@"https://api.instagram.com/oauth/access_token");
// define the request parameters
var requestObj = new Models.RequestAccessToken()
{
client_id = config.ClientId,
client_secret = config.ClientSecret,
grant_type = "authorization_code",
redirect_uri = config.RedirectURI,
code = code
};
// serialize the obj for transfer
var requestObjSer = JsonConvert.SerializeObject(requestObj);
// create the content obj
var content = new StringContent(requestObjSer, Encoding.UTF8, "application/json");
// make request for auth token
var response = await requestToken.PostAsync(authLinkUri, content);