2

I downloaded the windows phone 8 sdk and the sharepoint windows phone sdk.

Both installed fine.

But whenever I try to create a clientcontext and connect to a sharepoint (on premise and online) I just get the message in the execute query failed: Unable to connect to the site 'my url'. Please check that the network is available and the url is correct.

I tried both sharepoint online and on premise. Has anybody experience with the windows phone sharepoint sdk and can tell me why i cannot get a connection?

here is my code:

ClientContext ctx = new ClientContext("https://url/");

Authenticator auth = new Authenticator();
ctx.Credentials = auth;

web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQueryAsync(LoadOK, LoadFailed);
2
  • Have you solved this problem? this is exactly what I'm facing and I can't find anywhere a solution. :(
    – BMH
    Dec 3, 2014 at 18:53
  • Hi, unfortunately not. I use device channels and a mobile view of my sharepoint as workaraound, but I am not happy with the solution....
    – AdelPoint
    Dec 4, 2014 at 10:42

2 Answers 2

1

If you have SharePoint on-premises this code should work:

ClientContext m_Context = new ClientContext(SiteUrl);
NetworkCredential credentials = new NetworkCredential(Username, Password);
m_Context.Credentials = credentials;

If you would like to connect to SharePoint Online, the code should look like this (this will popup Office 365 login screen for user):

ClientContext m_Context = new ClientContext(SiteUrl);
Authenticator at = new Authenticator();
// Allows authenticator to save cookies for future usage
at.CookieCachingEnabled = true;                 
// In case of Microsoft Online federated authentication, set ADFS authentication scheme preference for passive authentication
// Example, to set client preference for SAML 2.0 username-password authentication scheme: 
at.FederationPassiveAuthUri = "urn:oasis:names:tc:SAML:2.0:ac:classes:Password"; 
m_Context.Credentials = at;
0

The Windows SDK is installed as part of the Desktop development with C++ workload in the Visual Studio Installer. A standalone version is available at Windows SDK. Open the shortcut menu for the project node, and choose Retarget projects. (In earlier versions of Visual Studio, choose Retarget SDK Version.)

Regards, Peter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.