Restsharp-响应中的无效请求

时间:2018-09-04 00:39:39

标签: c# rest web-services adobe restsharp

嗨,我正在使用restsharp发送发帖请求,但是,当我输出响应时出现错误。响应是

“ error_description \”:\“无效的授权码\”,\“ error \”:\“ invalid_request \”}“”

以下是我的网址的基本格式

 POST /oauth/token HTTP/1.1
 Host: api.au1.echosign.com
 Content-Type: application/x-www-form-urlencoded

 code=CBNCKBAAHBCAABAAveu8k6xdOsBSWT-q8U-GDupRldVEtdMH&
 client_id=CBJCHBCAABAAl8PzbSLzHEHbHdUY2UQ0un4S2WmUdJ_W&
 client_secret=psYcyZvQMfBYJVRI-jik9NhMKpD6vqyH&
 redirect_uri=https://www.google.com/&
 grant_type=authorization_code

下面是我实现的发送帖子请求并获得响应的方法。

  public string makeRequest()
  {
     string strResponse = string.Empty;

     ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

     var client = new RestClient("https://api.au1.echosign.com/oauth/token?");
     RestRequest request = new RestRequest() { Method = Method.POST };
     client.Authenticator = new HttpBasicAuthenticator("CBJCHBCAABAAl8PzbSLzHEHbHdUY2UQ0un4S2WmUdJ_W", "psYcyZvQMfBYJVRI-jik9NhMKpD6vqyH");
     request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
     request.AddParameter("code", "CBNCKBAAHBCAABAAveu8k6xdOsBSWT-q8U-GDupRldVEtdMH");
     request.AddParameter("redirect_uri", "https://www.google.com/");
     request.AddParameter("Host", "https://api.au1.echosign.com");
     request.AddParameter("grant_type", "authorization_code");
    // request.AddParameter("client_id", "CBJCHBCAABAAl8PzbSLzHEHbHdUY2UQ0un4S2WmUdJ_W");
    // request.AddParameter("client_secret", "psYcyZvQMfBYJVRI-jik9NhMKpD6vqyH");

     var response = client.Execute(request);
     Console.WriteLine(response.Content);
     return response.Content;
  }

我该如何解决这个问题?

谢谢

0 个答案:

没有答案