Correct SharePoint Online (2017) URL?

  • Thread starter Thread starter danyeungw
  • Start date Start date
D

danyeungw

Guest
I tried two scenarios. Both failed. The same login credential (user and password) works in SSIS package, so it is correct. I think the urls I used are not correct. What should the correct URL be? Thanks.

First: Error: The remote server returned an error: (403) Forbidden.


SecureString passWord = new SecureString();
foreach (char c in "abcd1234".ToCharArray()) passWord.AppendChar(c);

string argpath = "https://company.sharepoint.com/sites/DSS/Team/Recheck/Lists/Responses/_vti_bin/listdata.svc";
WebRequest req = WebRequest.Create(argpath);
req.UseDefaultCredentials = false
req.Credentials = new SharePointOnlineCredentials("user", passWord);

WebResponse response = req.GetResponse();
//response = req.GetResponse();

Second: Error: Cannot contact site at the specified URL https://company.sharepoint.com/sites/DSS/Team/Recheck/Lists/Responses/AllItems.aspx. There is no Web named "/sites/DSS/Team/Recheck/Lists/Responses/AllItems.aspx/_vti_bin/sites.asmx".

string argpath1 = "https://company.sharepoint.com/sites/DSS/Team/Recheck/Lists/Responses/AllItems.aspx";
using (var context = new ClientContext(argpath1))
{
context.Credentials = new SharePointOnlineCredentials("user", passWord);
Web web = context.Web;
context.Load(web.Lists,
lists => lists.Include(list => list.Title,
list => list.Id));
context.ExecuteQuery();
}

Continue reading...
 
Back
Top