我有curl请求,我想创建C#模拟。我的所有尝试都失败了。我尝试了在谷歌找到的所有东西。此说明API https://github.com/onlinerby/onliner-b2b-api/blob/master/docs/oauth20.md
这个卷曲
$process = curl_init("https://b2bapi.onliner.by/oauth/token");
curl_setopt($process, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($process, CURLOPT_USERPWD, "204da9b95e2480a3455f:7a4bbb61262fdf41d410645292a0489ba752c6b9");
curl_setopt($process, CURLOPT_POST, 1);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($process, CURLOPT_POSTFIELDS, array('grant_type' => 'client_credentials'));
$result = curl_exec($process);
curl_close($process);`
这是我的c#代码
string url = "https://b2bapi.onliner.by/oauth/token";
WebClient client = new WebClient();
client.Headers["Accept"] = "application/json";
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("204da9b95e2480a3455f:7a4bbb61262fdf41d410645292a0489ba752c6b9"));
client.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
var result = client.UploadString(url, "grant_type=client_credentials");`
请帮助我,我失去了很多时间......