C# 如何用restsharp写这个卷曲?

C# 如何用restsharp写这个卷曲?,c#,curl,restsharp,C#,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 |=

我挣扎着要把这个卷曲变成锐利的

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,然后我得到了缺少参数的错误

文档位于此链接上


经过几次测试和反复尝试,这似乎是可行的

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);