向在postman,C#Console Application上工作的api发送请求,但在asp.net应用程序中不工作

时间:2018-08-23 17:04:36

标签: api restsharp

我在ASP.NET应用程序中将Visual Studio 2010和RestSharp用于我的API调用,但是每次遇到BadRequest时,它都像C#控制台应用程序和Postman中的魅力一样工作。

Pstman Request

var client = new RestClient("https://accountsuat.cardconnect.com/auth/realms/cardpointe/protocol/openid-connect/token");
        var request = new RestRequest(Method.POST);
        request.AddHeader("Content-Type", "application/x-www-form-urlencoded");

        request.AddParameter("undefined", "username=" + username + "&password=" + password + "&grant_type=password" + "&client_id=copilot" + "&client_secret=" + client_secret, ParameterType.RequestBody);

        IRestResponse response = client.Execute(request);

0 个答案:

没有答案