如何在 restsharp 中编写此 cURL?
How to write this cURL in restsharp?
我正在努力将此 cURL 转换为 restsharp,
curl https://pwgateway.com/api/token \
-d "public_key=YOUR_PUBLIC_API_KEY" \
-d "card[number]=4000000000000002" \
-d "card[exp_month]=01" \
-d "card[exp_year]=2021" \
-d "card[cvv]=123"
我试过这样:
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
var client = new RestClient("https://api.paymentwall.com/api/brick/token");
var request = new RestRequest(Method.POST);
request.AddParameter("X-ApiKey", "privatekey",ParameterType.HttpHeader);
request.AddParameter("public_key", "publickey", ParameterType.HttpHeader);
request.AddParameter("card[number]", "4000000000000002", ParameterType.HttpHeader);
request.AddParameter("card[exp_month]", "01", ParameterType.HttpHeader);
request.AddParameter("card[exp_year]", "21", ParameterType.HttpHeader);
request.AddParameter("cardcard[cvv]", "123", ParameterType.HttpHeader);
我得到空字符串,还尝试从数据参数 public_key、card[number] 等中删除 ParameterType.HttpHeader,然后我得到缺少参数的错误。
关于此的文档 link
经过几次测试和尝试,这似乎有效
contentList.Add("card[cvv]=123");
contentList.Add("card[exp_year]=2021");
contentList.Add("card[exp_month]=01");
contentList.Add("card[number]=4000000000000002");
contentList.Add("public_key=mykey");
var body = string.Join("&", contentList);
request.AddParameter("application/x-www-form-urlencoded", body, ParameterType.RequestBody);
我正在努力将此 cURL 转换为 restsharp,
curl https://pwgateway.com/api/token \
-d "public_key=YOUR_PUBLIC_API_KEY" \
-d "card[number]=4000000000000002" \
-d "card[exp_month]=01" \
-d "card[exp_year]=2021" \
-d "card[cvv]=123"
我试过这样:
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
var client = new RestClient("https://api.paymentwall.com/api/brick/token");
var request = new RestRequest(Method.POST);
request.AddParameter("X-ApiKey", "privatekey",ParameterType.HttpHeader);
request.AddParameter("public_key", "publickey", ParameterType.HttpHeader);
request.AddParameter("card[number]", "4000000000000002", ParameterType.HttpHeader);
request.AddParameter("card[exp_month]", "01", ParameterType.HttpHeader);
request.AddParameter("card[exp_year]", "21", ParameterType.HttpHeader);
request.AddParameter("cardcard[cvv]", "123", ParameterType.HttpHeader);
我得到空字符串,还尝试从数据参数 public_key、card[number] 等中删除 ParameterType.HttpHeader,然后我得到缺少参数的错误。
关于此的文档 link
经过几次测试和尝试,这似乎有效
contentList.Add("card[cvv]=123");
contentList.Add("card[exp_year]=2021");
contentList.Add("card[exp_month]=01");
contentList.Add("card[number]=4000000000000002");
contentList.Add("public_key=mykey");
var body = string.Join("&", contentList);
request.AddParameter("application/x-www-form-urlencoded", body, ParameterType.RequestBody);