I am trying to post the request using the RestSharp client I / Pre> But I'm getting a response. StatusCode = How do I request how someone can help me by using the Bad Request Restsharp client. My Restart POST method: Public Zero ExchangeCodeForToken ( String code) {if (string.IsNullOrEmptE (code)) {OnAuthenticationFailed (); } Other {var requests = new resuware (this.TokenEndPoint, Method.POST); Request.AddParameter ("code", code); Request.AddParameter ("client_id", this.ClientId); request. Adapter ("client_select", this secret); Request.AddParameter ("redirect_uri", "vase: ietf: wg: oauth: 2.0: oob"); Request.AddParameter ("grant_type", "authorization_code"); Request.AddHeader ("content type", "application / x-www-form-url expired"); Client.ExecuteAsync & lt; AuthResult & gt; (Request, GetAccessToken); }} Zero GetAccessToken (IRestResponse & lt; AuthResult & gt; response) {if (response == faucet; response status code! = HttpStatusCode.OK || response data == faucet} string. INLLOLTY (feedback data. EkS_Tokan)) {OnAuthenticationFailed (); } Else {Debug.Assert (response.Data! = Null); AuthResult = response.Data; OnAuthenticated (); }}
Var client = new rest client (ServiceUrl); Var request = new rasterwent ("/ resource /", method. POST); // Json String to post to jsonToSend = JsonHelper.ToJson (json); Request.AddParameter ("Application / Jason; Charset = UTF-8", JasonTosend, Parameter Type.); Request.RequestFormat = DataFormat.Json; {Client.ExecuteAsync (Request, Feedback => {(response.StatusCode == HttpStatusCode.OK) {// OK} Other {// NOK}}) Try it; } Hold (exception error) {// log}
Comments
Post a Comment