Stack Exchange
Problem with Restsharp to send parameter in x-urlen-body-encoded in Get Method
I have a api with Get Method that sends data in x-urlen-body-encoded. In postman, curl it is working fine we are getting response data.
In restsharp (C#) i encountered error saying that one of the parameter is not send.
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/rsBillingApi/v2/soapbox/liveassets/genre?generId=3&platformId=1", Method.Get);
request.AddHeader("x-access-token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTUyNTE4LCJpYXQiOjE2OTkzNTEwOTYsImV4cCI6MTY5OTM1NDY5Nn0.xrvQZCRdQImwKtbnAeeRzhi2M9yW2W6RJR6xlU0hgts");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("genreId", "3");
request.AddParameter("platformId", "1");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);

--header 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTUyNTE4LCJpYXQiOjE2OTkzNTEwOTYsImV4cCI6MTY5OTM1NDY5Nn0.xrvQZCRdQImwKtbnAeeRzhi2M9yW2W6RJR6xlU0hgts' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'genreId=3' \
--data-urlencode 'platformId=1'

Could any one suggest how can i send parameter in restsharp.
I also tried same api in python using request library and i am getting correct result. In python it is sending data in payload using genreId=3&platformId=1 format. I am confused why this weired behavior is
import requests

url = "https://domain.net.xyz/rsBillingApi/v2/soapbox/liveassets/genre?generId=3&platformId=1"

payload = 'genreId=3&platformId=1'
headers = {
  'x-access-token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTUyNTE4LCJpYXQiOjE2OTkzNTEwOTYsImV4cCI6MTY5OTM1NDY5Nn0.xrvQZCRdQImwKtbnAeeRzhi2M9yW2W6RJR6xlU0hgts',
  'Content-Type': 'application/x-www-form-urlencoded'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)


{
   MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/rsBillingApi/v2/soapbox/liveassets/genre? 
                  generId=3&platformId=1", Method.Get);
request.AddHeader("x-access-token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTUyNTE4LCJpYXQiOjE2OTkzNTEwOTYsImV4cCI6MTY5OTM1NDY5Nn0.xrvQZCRdQImwKtbnAeeRzhi2M9yW2W6RJR6xlU0hgts");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
 request.AddParameter("application/x-www-form-urlencoded", "generId=3&platformId=1", ParameterType.RequestBody)
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);

this should work

As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
