I am Trying to send api key as header in Rest sharp, This is what I am trying,
I am getting {"status":403,"message":"Forbidden"}
public static IRestResponse CreateNewUser(string enviroment, string email, string password)
{
NameValueCollection Env = ValidateEnv(enviroment);
string baseurlenv = Env["baseApiURL"];
var enviroments = new EndPointProviders();
var Client = new RestClient();
Client.BaseUrl = new Uri(baseurlenv);
var request = new RestRequest(Method.POST);
request.Resource = string.Format("/v3/members/email={0}&password={1}&terms_and_conditions=true", email, password);
request.AddHeader("x-api-key", "yxyxyxyx");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
IRestResponse response = Client.Execute(request);
Console.WriteLine(request);
if (!IsReturnedStatusCodeOK(response))
{
throw new HttpRequestException("Request issue -> HTTP code:" + response.StatusCode);
}
return response;
}
I managed to get the same request in Python Which works fine how can I do the same thing in Rest sharp?
import requests
# Create User/
headers = {
'Host': 'host..',
'x-api-key': 'yxyxyxyx',
'content-type': 'application/x-www-form-urlencoded',
}
data = 'email=example18@gmail.com&password=example1&terms_and_conditions=true'
response = requests.post('https://sampeurl/v3/members', headers=headers, data=data)
print(response.content)