You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
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:@"[email protected]"];
[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
The text was updated successfully, but these errors were encountered:
I think the issue is that -[getSerializedDataWithError:] in MSObject serializes the dictionary shallowly. In my case, it tries to create a JSON out of a dictionary that contains an MSGraphFolder value, which it cannot do. Before that's possible, it has to serialize that object into a dictionary. Basically, MSObject has to serialize the dictionary deeply. Or make sure that the dictionary never contains invalid objects in the first place, see NSJSONSerialization documentation.
tobihagemann
added a commit
to tobihagemann/msgraph-sdk-objc-models
that referenced
this issue
Oct 8, 2019
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:@"[email protected]"];
[emailAddress setName:@"Tim Cook"];
[emailAddressesList addObject: emailAddress];
[contact setEmailAddresses:emailAddressesList];
Please clarify 2 things:
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
The text was updated successfully, but these errors were encountered: