我在 c# 中运行以下命令向 API 发送登录请求。但是,根据 Fiddler 的说法,它没有发送身份验证标头。我是菜鸟,所以可能很简单。
NetworkCredential netcreds=new NetworkCredential(username,password);
CredentialCache credentials = new CredentialCache();
credentials.Add(new Uri(LoginUrl.ToString()),"Basic",netcreds);
Uri LoginUri = new Uri(LoginUrl);
WebRequest AuthRequest = WebRequest.Create(LoginUri);
AuthRequest.Credentials = credentials; `
AuthRequest.Headers.Add(HttpRequestHeader.AcceptEncoding,@"application/*+xml;version=1.5");`