Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Accessing SharePoint Online

I'm really stuck trying to connect an Android app to Office 365.

Has anyone been successful to do this in a Xamarin app?
There is not many samples or documentation out there and would really appreciate any help.

I'm in first step of authentication, using this sample:
http://blog.xamarin.com/add-storage-to-your-apps-with-office-365/

I got this exception

Java.Lang.RuntimeException: java.lang.reflect.InvocationTargetException at --- End of managed exception stack trace --- at java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at at dalvik.system.NativeStart.main(Native Method) at Caused by: java.lang.reflect.InvocationTargetException at at java.lang.reflect.Method.invokeNative(Native Method) at at java.lang.reflect.Method.invoke(Method.java:515) at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at ... 2 more at Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: Microsoft.Office365.Discovery.DiscoveryFailedException: Exception of type 'Microsoft.Office365.Discovery.DiscoveryFailedException' was thrown. at at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x0004b> at at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (object) <IL 0x00006, 0x0003b> at Android.App.SyncContext/<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18 at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36 at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Java.Lang.IRunnable.cs:71 at at (wrapper dynamic-method) object.53a635e4-c3ae-4264-99f1-cc204228b19f (intptr,intptr) <IL 0x00011, 0x00027> at at mono.java.lang.RunnableImplementor.n_run(Native Method) at at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29) at at android.os.Handler.handleCallback(Handler.java:733) at at android.os.Handler.dispatchMessage(Handler.java:95) at at android.os.Looper.loop(Looper.java:136) at at android.app.ActivityThread.main(ActivityThread.java:5017) at ... 5 more

After that I have updated MainActivity to inherit from Activity and after the authentication I got a web view telling me that the website with the url of my Active Directory in Azure is not available. When the app is closed I got this exception.

Java.Lang.RuntimeException: java.lang.reflect.InvocationTargetException at --- End of managed exception stack trace --- at java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at at dalvik.system.NativeStart.main(Native Method) at Caused by: java.lang.reflect.InvocationTargetException at at java.lang.reflect.Method.invokeNative(Native Method) at at java.lang.reflect.Method.invoke(Method.java:515) at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at ... 2 more at Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object at OneDriveIntegrationSample.MainActivity.OnCreate (Android.OS.Bundle) [0x00015] in c:\Users\jorge.riberia\Desktop\O365ClientV2-master\OneDriveIntegrationSample\MainActivity.cs:37 at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.App.Activity.cs:2475 at at (wrapper dynamic-method) object.ef571741-4aae-43aa-a83a-300a943e9da1 (intptr,intptr,intptr) <IL 0x00017, 0x0002b> at at md5660544361ce26a28c7fa23eec85388e3.MainActivity.n_onCreate(Native Method) at at md5660544361ce26a28c7fa23eec85388e3.MainActivity.onCreate(MainActivity.java:28) at at android.app.Activity.performCreate(Activity.java:5231) at at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) at at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at at android.app.ActivityThread.access$800(ActivityThread.java:135) at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at at android.os.Handler.dispatchMessage(Handler.java:102) at at android.os.Looper.loop(Looper.java:136) at at android.app.ActivityThread.main(ActivityThread.java:5017) at ... 5 more

Tagged:

Posts

  • JorgeSanzJorgeSanz USMember

    I get now the AccesToken with this code:

    var authContext = new AuthenticationContext(commonAuthority); if (authContext.TokenCache.ReadItems().Count() > 0) authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority); authResult = await authContext.AcquireTokenAsync(DiscoveryServiceResourceId, clientId, returnUri, new AuthorizationParameters(this));

    public static readonly string DiscoveryServiceResourceId = "https://api.office.com/discovery/"; public static string commonAuthority = "https://login.windows.net/common";

    I would like to make a request to the SharePoint Online API, I'm using this code:

    var url = "http://domain.sharepoint.com/sites/Demo/_api/web/lists";

    HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create(url); endpointRequest.Method = "GET"; endpointRequest.Accept = "application/json;odata=verbose"; endpointRequest.Headers.Add("Authorization", "Bearer " + authResult.AccessToken); HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse();

    But I get this response:
    ex {System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result) [0x0033b] in <filename unknown>:0 at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00165] in <filename unknown>:0 } System.Net.WebException

    Isn't this a valid GET request?
    Am I missing something obvious?
    Thanks

  • BjrnLindstrmBjrnLindstrm SEMember

    I got this error for the first time today. I am building an app that connects to an Azure mobile service backend. It has been working for the past 3 months but today all of a sudden i am getting this error thrown all over the place. But i ALWAYS get it thrown directly after authentication closes and before OnCreate is called on the activity that should be launched after authentication. If i put breakpoints here it works but often crashes at a later time with the same exception. Since the thing that has changed is my version of XamarinStudio i suspect that might be the cause.

  • JorgeSanzJorgeSanz USMember

    Thanks, I'll try to download another version of Xamarin Studio will let you know

  • JorgeSanzJorgeSanz USMember

    I actually have tried with 4 different versions of Xamarin Studio and I get same error in all of them using the sample I have mentioned.

  • RasmusRaakjrVindRasmusRaakjrVind USMember

    did you find a fix for the "java.lang.reflect.InvocationTargetException"?

  • JorgeSanzJorgeSanz USMember

    No I didn't, tried with different Xamarin versions and Windows 7 and 8.1 and same error.

  • RasmusRaakjrVindRasmusRaakjrVind USMember

    Dammit :( i am fighting it atm and cant figure it out...

  • heli_shahheli_shah Member ✭✭

    Anyone tried this?

  • alexmaniealexmanie ESMember ✭✭

    stucked at the same point :(

Sign In or Register to comment.