我正在尝试连接到salesforce沙箱环境,但我收到状态码400错误。以下是我的代码。
我的登录终点是:https://test.salesforce.com/services/oauth2/token
public Dictionary<string, string> Login()
{
String jsonResponse;
using (var client = new HttpClient())
{
var request = new FormUrlEncodedContent(new Dictionary<string, string>
{
{"grant_type", "password"},
{"client_id", clientId},
{"client_secret", clientSecret},
{"username", userName},
{"password", password}
});
request.Headers.Add("X-PrettyPrint", "1");
var response = client.PostAsync(loginEndpoint, request).Result;
jsonResponse = response.Content.ReadAsStringAsync().Result;
}
var values = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonResponse);
return values;
}