Getting error in rest api c#

 public static async Task<RxTokenDataResponse> GetDataAsync(string code)


         var options = new RestClientOptions("");
         var client = new RestClient(options);

         var request = new RestRequest();
         request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
         request.AddHeader("accept", "application/json");

             client_id = RnUrlConfig.ApiKey,
             client_secret = RnUrlConfig.ApiSecret,
             redirect_uri = RnUrlConfig.RedirectUrl,
             grant_type = "authorization_code"
         }); ;
         // The cancellation token comes from the caller. You can still make a call without it.
         var data = await client.PostAsync(request);
         return null;
     catch (Exception ex)
         Exception p = ex;
         return null;

I tried everything, but only getting “Request failed with status code BadRequest” response

Could you please confirm if the following cURL request functions correctly for you?

curl -X 'POST' '' \
-H 'accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'code={your_code}&client_id={your_client_id}&client_secret={your_client_secret}&redirect_uri={your_redirect_url}&grant_type=authorization_code'

Ensure to modify the query parameters according to your application.