May 08 2018 07:18 AM
Hi All.
Since yesterday my c# code stopped working when trying to access SPS Online (and Project PWA in specific) through HttpWebRequest interface while CSOM continue to work as expected.
in both cases I use the same SharePointOnlineCredentials: while CSOM calls return successfully, the HttpWebRequest now fails with a 401 Unauthorized.
Same code worked until yesterday; any idea?
Thank you !
Paolo
May 08 2018 08:29 AM
May 08 2018 08:14 PM
SolutionHi,
Just FYI, here is the piece of updated code i have used and now it is working fine.
The one in BOLD is the new line of code that i have used to make it working.
SecureString passWord = new SecureString();
foreach (char c in m_Password.ToCharArray()) passWord.AppendChar(c);
var credentials = new SharePointOnlineCredentials("UserName, passWord);
string metaDataURL = "ProjectOnlineURL";
var req = (HttpWebRequest)WebRequest.Create(metaDataURL);
req.Credentials = credentials;
req.Headers["X-FORMS_BASED_AUTH_ACCEPTED"] = "f";
req.Headers.Add(HttpRequestHeader.Cookie, credentials.GetAuthenticationCookie(new Uri(metaDataURL)));
var resp = (HttpWebResponse)req.GetResponse();
Regards,
Sunil G.
May 08 2018 10:28 PM
May 08 2018 10:30 PM
May 09 2018 01:36 AM
For anyone interested in: https://pwmather.wordpress.com/2018/05/09/change-required-for-sharepoint-online-projectonline-rest-a...
May 08 2018 08:14 PM
SolutionHi,
Just FYI, here is the piece of updated code i have used and now it is working fine.
The one in BOLD is the new line of code that i have used to make it working.
SecureString passWord = new SecureString();
foreach (char c in m_Password.ToCharArray()) passWord.AppendChar(c);
var credentials = new SharePointOnlineCredentials("UserName, passWord);
string metaDataURL = "ProjectOnlineURL";
var req = (HttpWebRequest)WebRequest.Create(metaDataURL);
req.Credentials = credentials;
req.Headers["X-FORMS_BASED_AUTH_ACCEPTED"] = "f";
req.Headers.Add(HttpRequestHeader.Cookie, credentials.GetAuthenticationCookie(new Uri(metaDataURL)));
var resp = (HttpWebResponse)req.GetResponse();
Regards,
Sunil G.