我正在尝试转换以下curl命令
curl --location --request GET "https://xxx.xxxx.xxx/artifacts?session=016e1f70-d9da-41bf-b93d-80e281236c46&path=/home/gauntlet_gameye/LinuxServer/Game/Saved/Logs/Game.log" -H "Authorization:Bearer xxxx" -H "Accept:application/json" --output C:\Temp\Game.log
转换成C#代码,我有以下代码
string SessionId = "016e1f70-d9da-41bf-b93d-80e281236c46";
string Token = "xxxx";
string FilePath = "/home/gauntlet_gameye/LinuxServer/Game/Saved/Logs/Game.log";
string Endpoint = string.Format("https://xxx.xxxx.xxx/artifacts?session={0}&path={1}", SessionId, FilePath);
HttpRequestMessage HttpRequestMsg = new HttpRequestMessage();
HttpRequestMsg.RequestUri = new Uri(Endpoint);
HttpRequestMsg.Method = HttpMethod.Get;
HttpRequestMsg.Headers.Add("Accept", "application/json");
HttpRequestMsg.Headers.Add("Authorization", string.Format("Bearer {0}", Token));
HttpRequestMsg.Content = new StringContent(string.Format("--output {0}", OutFilePath), Encoding.UTF8, "application/json");
using (HttpClient Client = new HttpClient())
{
var HttpResponseTask = Client.SendAsync(HttpRequestMsg);
}
但它提供了以下异常信息
Cannot send a content-body with this verb-type.
1条答案
按热度按时间nzkunb0c1#
来源:Convert curl commands to C#