看起来你的c中有一个错误,它已经指向你了,但它必须是
members?email
不
members/email
如果您正在处理aws api网关,后者将注册为一个完全不同的端点,这可能会导致各种奇怪的状态代码向您抛出,403在这种情况下实际上是可以接受的。
接下来,我将使用以下方法,而不是像您这样向url添加参数:
request.AddParameter(string name, string value);
你上面写的一个例子是
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);
// Resource should just be the path
request.Resource = string.Format("/v3/members);
// This is how to add parameters
request.AddParameter("email", email);
request.AddParameter("password", password);
request.AddParameter("terms-and-conditions", "true");
// This looks correct assuming you are putting your actual x-api-key here
request.AddHeader("x-api-key", "yxyxyxyx");
// There is a chance you need to configure the aws api gateway to accept this content type header on that resource. Depends on how locked down you have it
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;
}