Sharepoint _api/Web/Lists API에 대한 액세스 권한이 필요합니다. 나는 내 HttpWebRequest
에 삽입 할 FedAuth 쿠키를 가지고 있습니다. 이 내가 다음 헤더 오류와 WebException
이 내 코드HttpWebRequest Sharepoint API 인증 FedAuth 401
ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)Delegate.Combine(ServicePointManager.ServerCertificateValidationCallback, new RemoteCertificateValidationCallback((object SearchOption, X509Certificate cert, X509Chain chain, SslPolicyErrors sslerror) => true));
var requestUri = this._gedBaseUrl + @"_api/Web/Lists/GetByTitle('Title')/items?$filter=SomeKey eq 'SomeValue'";
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUri);
httpWebRequest.UserAgent = @"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko";
httpWebRequest.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
httpWebRequest.Method = WebRequestMethods.Http.Get;
httpWebRequest.AllowAutoRedirect = false;
httpWebRequest.Accept = @"text/html,application/xhtml+xml,*/*";
httpWebRequest.CookieContainer = new CookieContainer();
httpWebRequest.CookieContainer.Add(cookie);
try
{
HttpWebResponse endpointResponse = (HttpWebResponse)httpWebRequest.GetResponse();
}
catch (Exception e)
{
throw e;
}
입니다 :
((WebException)e).Response.Headers["X-MSDAVEXT_Error"] "917656; Access denied. Before opening files in this location, you must first browse to the web site and select the option to login automatically."
그래서 내 브라우저의 쿠키를보고 결정을, 나는 같은 일 해당 UserAgent과 FedAuth를 보낸다 값.
그래서 나는 HTTP 결과와 붙어 401
이 코드 작동 미세 (HTTP 200 결과) 나는 또한에 httpWebRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
를 추가하려고 @"_api/Web/Lists/GetByTitle('Title')/items?$filter=SomeKey eq 'SomeValue'";
없이 URL에 액세스하려면 내 헤더.
잘 이해하면이 헤더는 셰어 포인트 서버에 NTLM 인증을 사용하도록 요청합니다.이 인증 방법은 내 인증 방법이 FedAuth systeme을 기반으로하기 때문에 원하는 것이 아닙니다.
나는 뭔가를 놓치고 있다고 생각합니다. 마지막으로
그냥 httpWebRequest.Headers.Add ("X-FORMS_BASED_AUTH_ACCEPTED", "f")를 추가하십시오. 내 요청에 더 이상 같은 헤더 응답이 없지만 401 오류가 여전히 있습니다. / – pix