开发者

logging in sharepoint through c# programatically

开发者 https://www.devze.com 2023-03-24 07:16 出处:网络
I am trying to login programatically to a sharepoint app and get the html code of specific page within that website.

I am trying to login programatically to a sharepoint app and get the html code of specific page within that website. Is there a way how I can do that programatically? I am having problems with the part where I need to pass the login parameters and access the url I need to get the html code. Thanks in advance everyone, Laziale

 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://mysite.sharepoint.com");
        NetworkCredential credentials = new NetworkCredential(开发者_如何转开发"myUser", "myPass");
        request.Credentials = credentials;

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream receiveStream = response.GetResponseStream ();

        StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
        string html = readStream.ReadToEnd();

        response.Close();
        readStream.Close();


Have you tried something like:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("url goes here");
request.Credentials = new NetworkCredential("username", "password");

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream ();

StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
string html = readStream.ReadToEnd();

response.Close();
readStream.Close();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号