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

Description
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:
- why the method terminates rather than report the error?
- 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