标签:sharepoint sharepoint 2013 rest
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://ap.2013.trial.nintex.com/_api/web/"); request.Accept = "application/json;odata=verbose"; NetworkCredential myCredential = new NetworkCredential("Justin.Liu1", "3QF0\"gn", "EXT"); request.Credentials = myCredential; WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader sr = new StreamReader(stream); string content = sr.ReadToEnd();
NetworkCredential myCredential = new NetworkCredential("Justin.Liu1", "3QF0\"gn", "EXT");
ClientContext ctx = new ClientContext("https://ap.2013.trial.nintex.com/");
ctx.Credentials = myCredential;
Web web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQuery();
string title = web.Title;
//Site URL: https://ap.2013.trial.nintex.com
//Username: EXT\Justin.Liu1
//Password: 3QF0"gn
var soapEnv = string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soap:Body>
<Login xmlns=""http://schemas.microsoft.com/sharepoint/soap/"">
<username>{0}</username>
<password>{1}</password>
</Login>
</soap:Body>
</soap:Envelope>","EXT\\Justin.Liu1","3QF0\"gn");
byte[] data = Encoding.UTF8.GetBytes(soapEnv);
HttpWebRequest loginRequest = (HttpWebRequest)WebRequest.Create("https://ap.2013.trial.nintex.com/_vti_bin/Authentication.asmx");
loginRequest.Headers["SOAPAction"] = "http://schemas.microsoft.com/sharepoint/soap/Login";
loginRequest.Method = "POST";
loginRequest.ContentType = "text/xml; charset=utf-8";
loginRequest.ContentLength = data.Length;
Stream requestStream = loginRequest.GetRequestStream();
requestStream.Write(data, 0, data.Length);
requestStream.Close();
WebResponse loginResponse = loginRequest.GetResponse();
Stream loginStream = loginResponse.GetResponseStream();
StreamReader lsr = new StreamReader(loginStream);
string loginContent = lsr.ReadToEnd();
requestStream.Close();
标签:sharepoint sharepoint 2013 rest
原文地址:http://blog.csdn.net/foxdave/article/details/44728109