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 '14 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 '14 at 10:42
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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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