Skip to content
This repository was archived by the owner on Apr 18, 2023. It is now read-only.
This repository was archived by the owner on Apr 18, 2023. It is now read-only.

'Invalid type in JSON write (MSGraphEmailAddress)' #27

@SteveDCronin

Description

@SteveDCronin

In trying to create a new contact I am continuing to use the Objective-C code snippet here:
https://docs.microsoft.com/en-us/graph/api/user-post-contacts?view=graph-rest-1.0&tabs=objc

It occurs here:
contact = [[MSGraphContact alloc] init];
...
NSError *error=nil;
NSData *contactData = [contact getSerializedDataWithError:&error];

There error is:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (MSGraphEmailAddress)'

The contact has a single email address constructed like this:
NSMutableArray *emailAddressesList = [[NSMutableArray alloc] init];
MSGraphEmailAddress *emailAddress = [[MSGraphEmailAddress alloc] init];
[emailAddress setAddress:@"tim@apple.com"];
[emailAddress setName:@"Tim Cook"];
[emailAddressesList addObject: emailAddress];
[contact setEmailAddresses:emailAddressesList];

Please clarify 2 things:

  1. why the method terminates rather than report the error?
  2. what am I doing wrong in constructing the MSGraphEmailAddress

Thanks you any help.

BTW: further testing shows that I get the same type error if I construct an address:
'NSInvalidArgumentException', reason: 'Invalid type in JSON write (MSGraphPhysicalAddress)'
AB#7053

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions