public static async Task<RxTokenDataResponse> GetDataAsync(string code)
{
try
{
var options = new RestClientOptions("https://api.upstox.com/v2/login/authorization/token");
var client = new RestClient(options);
var request = new RestRequest();
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("accept", "application/json");
request.AddBody(new
{
code,
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