OfficeDev / Office-365-SDK-for-iOS

Microsoft Services SDKs for iOS Preview produced by MS Open Tech.
https://dev.office.com/
Other
96 stars 49 forks source link

getContacts not loading response into the object model #50

Closed MIchaelMainer closed 9 years ago

MIchaelMainer commented 9 years ago

Code to get contacts (contacts NSArray is empty):

// Get the Outlook Services client.
[[BaseController alloc] getMailClient:^(MSOutlookClient *client) {

    // Get the first page of contacts. This results in a call to the service.
    NSURLSessionDataTask* task = [[[client getMe] getContacts] read:^(NSArray<MSOutlookContact> *contacts, MSODataException *error)
    {

Response

{ "@odata.context": "https://outlook.office365.com/api/v1.0/$metadata#Me/Contacts", "value": [{ "@odata.id": "https://outlook.office365.com/api/v1.0/Users('systemadmin@XXXXX.onmicrosoft.com')/Contacts('AAMkADg5ZDhjZTYC7AAA=')", "@odata.etag": "W/\"EQAARp1VTV+24eiEAAATULRr\"", "Id": "A7AAA=", "ChangeKey": "EQAAATULRr", "Categories": [], "DateTimeCreated": "2015-02-05T07:17:29Z", "DateTimeLastModified": "2015-02-05T07:17:29Z", "ParentFolderId": "AAMOAAA=", "Birthday": null, "FileAs": "", "DisplayName": "John Brown", "GivenName": "John", "Initials": null, "MiddleName": null, "NickName": null, "Surname": "Brown", "Title": null, "Generation": null, "EmailAddresses": [null, null, null], "ImAddresses": [null, null, null], "JobTitle": null, "CompanyName": null, "Department": null, "OfficeLocation": null, "Profession": null, "BusinessHomePage": null, "AssistantName": null, "Manager": null, "HomePhones": [null, null], "BusinessPhones": [null, null], "MobilePhone1": "4255551212", "HomeAddress": { "Street": null, "City": null, "State": null, "CountryOrRegion": null, "PostalCode": null }, "BusinessAddress": { "Street": null, "City": null, "State": null, "CountryOrRegion": null, "PostalCode": null }, "OtherAddress": { "Street": null, "City": null, "State": null, "CountryOrRegion": null, "PostalCode": null }, "YomiCompanyName": null, "YomiGivenName": null, "YomiSurname": null }

This result is not accessible in the object model. The contacts array is empty.

mikolalv123 commented 9 years ago

Good day, I have same issue, it is actually returning data but parser crashes with exception.

Workaround for me was to return data as raw and parse myself.

mikolalv123 commented 9 years ago

Here is fast example: [[BaseController alloc] getClient:^(MSOutlookClient client) { NSURLSessionTask task = [[[client getMe] getContacts ] readRaw:^(NSString contact, NSError error) {

        if(error == nil){
            dispatch_async(dispatch_get_main_queue(),
                           ^{

                               NSArray * jsonArray = [NSJSONSerialization JSONObjectWithData:[contact dataUsingEncoding:NSUTF8StringEncoding] options: NSJSONReadingMutableContainers error:nil];

                               NSArray *jsonResult;
                               jsonResult = [jsonArray valueForKey:@"value"];

                           });
        }
MIchaelMainer commented 9 years ago

mikolalv123, Thank you! I need to update my pods so I can use that. Great find!