Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Using Office 365 API in Xamarin.Android

$
0
0

I am creating a sample for a talk: using Office 365 in Xamarin.Android, but I am having some errors, don´t know why :/

I got this:

"System.InvalidOperationException: An error occurred while processing this request. --->
Microsoft.OData.Client.DataServiceTransportException: Error: NameResolutionFailure --->
System.Net.WebException: Error: NameResolutionFailure\n
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.HttpWebRequestMessage.EndGetResponse (IAsyncResult asyncResult) [0x00000]
in :0 \n --- End of inner exception stack trace ---\n
at Microsoft.OData.Client.HttpWebRequestMessage.EndGetResponse (IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.ODataRequestMessageWrapper.EndGetResponse (IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.DataServiceContext.GetResponseHelper (Microsoft.OData.Client.ODataRequestMessageWrapper request, IAsyncResult asyncResult, Boolean handleWebException) [0x00000]
in :0 \n --- End of inner exception stack trace ---\n
at Microsoft.OData.Client.BaseAsyncResult.EndExecute[QueryResult] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.QueryResult.EndExecuteQuery[Contact] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n--- End of stack trace from previous location where exception was thrown ---\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0 \n
at System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.Office365.Exchange.Extensions.IPagedEnumerable1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000]
in :0 \n at Microsoft.Office365.Exchange.Extensions.DataServiceContextWrapper+d__2d2[Microsoft.Office365.Exchange.Contact,Microsoft.Office365.Exchange.IContact].MoveNext () [0x00000] in <filename unknown>:0 \n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 \n at System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.Office365.Exchange.Extensions.IPagedEnumerable1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000] in <filename unknown>:0 \n at Office365InXamarinApps.ViewModel.ContactsViewModel+<GetContacts>d__3.MoveNext () [0x000b5] in d:\\DevApps\\GitHub\\Office365InXamarinApps\\scr\\Office365InXamarinApps\\Office365InXamarinApps\\ViewModel\\ContactsViewModel.cs:44 \n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 \n at System.Runtime.CompilerServices.TaskAwaiter1[System.Collections.Generic.IEnumerable`1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000]
in :0 \n at Office365InXamarinApps.ViewModel.ContactsViewModel+d__0.MoveNext () [0x00030]
in d:\DevApps\GitHub\Office365InXamarinApps\scr\Office365InXamarinApps\Office365InXamarinApps\ViewModel\ContactsViewModel.cs:25 " string

and this

"Microsoft.OData.Core.ODataErrorException: Object reference not set to an instance of an object.
---> Microsoft.OData.Client.DataServiceQueryException: An error occurred while processing this request.
---> Microsoft.OData.Client.DataServiceClientException: {\"error\":{\"code\":\"ErrorInternalServerError\",\"message\":\"Object reference not set to an instance of an object.\",\"innererror\":{\"message\":\"Object reference not set to an instance of an object.\",\"type\":\"System.NullReferenceException\",\"stacktrace\":\"
at Microsoft.Exchange.Services.OData.Model.ContactSchema.<.cctor>b__2c(Entity e, PropertyDefinition ep, ServiceObject s, PropertyInformation sp)\r\n
at Microsoft.Exchange.Services.OData.Model.SimpleEwsPropertyProvider.GetProperty(Entity entity, PropertyDefinition property, ServiceObject ewsObject)\r\n
at Microsoft.Exchange.Services.OData.Model.ContactProvider.ItemTypeToEntity(ItemType itemType, IList1 properties)\\r\\n at Microsoft.Exchange.Services.OData.Model.ContactProvider.Find(String parentFolderId, ContactQueryAdapter queryAdapter)\\r\\n at Microsoft.Exchange.Services.OData.Model.FindContactsCommand.InternalExecute()\\r\\n at Microsoft.Exchange.Services.OData.ODataCommand2.Execute()\r\n
at Microsoft.Exchange.Services.OData.ODataTask.Execute(TimeSpan queueAndDelayTime, TimeSpan totalTime)\"}}}\n
at Microsoft.OData.Client.BaseAsyncResult.EndExecute[QueryResult] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.QueryResult.EndExecuteQuery[Contact] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n --- End of inner exception stack trace ---\n
at Microsoft.OData.Client.QueryResult.EndExecuteQuery[Contact] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.DataServiceRequest.EndExecute[Contact] (System.Object source, Microsoft.OData.Client.DataServiceContext context, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n--- End of stack trace from previous location where exception was thrown ---\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0 \n at System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.Office365.Exchange.Extensions.IPagedEnumerable1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000] in :0 \n
at Microsoft.Office365.Exchange.Extensions.DataServiceContextWrapper+d__2d2[Microsoft.Office365.Exchange.Contact,Microsoft.Office365.Exchange.IContact].MoveNext () [0x00000] in <filename unknown>:0 \n --- End of inner exception stack trace ---\n at Microsoft.Office365.Exchange.Extensions.DataServiceContextWrapper+<ExecuteAsync>d__2d2[Microsoft.Office365.Exchange.Contact,Microsoft.Office365.Exchange.IContact].MoveNext () [0x00000]
in :0 \n--- End of stack trace from previous location where exception was thrown ---\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0 \n at System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.Office365.Exchange.Extensions.IPagedEnumerable1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000] in :0 \n
at Office365InXamarinApps.ViewModel.ContactsViewModel+d__4.MoveNext () [0x000d7] in d:\DevApps\GitHub\Office365InXamarinApps\scr\Office365InXamarinApps\Office365InXamarinApps\ViewModel\ContactsViewModel.cs:53 " string

Here:

public async Task<IEnumerable> GetContacts(Context context)
{ try
{
var client = await EnsureClientCreated(context);

            // Obtain first page of contacts
            var contactsResults = await (from i in client.Me.Contacts
                                         orderby i.DisplayName
                                         select i).Take(20).ExecuteAsync();

            return contactsResults.CurrentPage;
        }
        catch (Exception exception)
        {
            //todo handle this
            var error = exception.ToString();
        }
        return null;
    }</code>

in this file:
https://github.com/saramgsilva/Office365InXamarinApp/blob/master/scr/Office365InXamarinApps/Office365InXamarinApps/ViewModel/ContactsViewModel.cs

The code is here: https://github.com/saramgsilva/Office365InXamarinApp


Viewing all articles
Browse latest Browse all 58056

Trending Articles