Вызов API для получения токена, получение неверного запроса в. Net Framework, Ok 200 in. Net Core - тот же класс - PullRequest
0 голосов
/ 06 марта 2020

Я получаю 400 неверных запросов в. Net фреймворке с кодом ниже.

Тот же код успешно выполняется. Net ядро ​​с ok 200, и я получаю токен доступа

Я также пытался заменить HttpClient на WebClient

Кто-нибудь может подсказать, что может вызвать это?

var url = _baseUrl + "token";
    HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);

    var grantType = "password";
    var integrated = "N";

    var username = ConfigurationManager.AppSettings["Deltek.Username"];
    var password = ConfigurationManager.AppSettings["Deltek.Password"];
    var database = ConfigurationManager.AppSettings["Deltek.DatabaseName"];
    var clientId = ConfigurationManager.AppSettings["Deltek.ClientId"];
    var clientSecret = ConfigurationManager.AppSettings["Deltek.ClientSecret"];

    Dictionary<string, string> values = new Dictionary<string, string>();
    values.Add("username", username);
    values.Add("password", password);
    values.Add("grant_type", grantType);
    values.Add("integrated", integrated);
    values.Add("database", database);
    values.Add("client_Id", clientId);
    values.Add("client_secret", clientSecret); // _keyvaultservice.getSecret(keyvault + secretname)

    var content = new FormUrlEncodedContent(values);

    request.Content = content;

    var response = await _client.SendAsync(request);
    string json = await response.Content.ReadAsStringAsync();
    return await response.Content.ReadAsAsync<DeltekToken>();
...