我在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");`