Incorrect type for "Identity" in "IdentitySet"
The type Identity seems to be different from what the API is returning. This error occured for us when retrieving the identity of the creator of the document using the createdBy.user field on a DriveItem.
Expected (declared in microsoft-graph.d.ts line 8736)
{
id?: string;
displayName?: string;
}
Returned by API
{
email: "some.email@domain",
displayName: "Some Name"
}
We tried to switch to the beta types but they are the same.
We are for now casting the createdBy.user property to what the API is returning.
AB#7046
This is expected behavior per the metadata. This is an OpenType which means that undefined properties may be returned in this object. Additionally, id and displayName are nullable so it is expected that they may not be present in a response.
<ComplexType Name="identity" OpenType="true">
<Property Name="displayName" Type="Edm.String" />
<Property Name="id" Type="Edm.String" />
</ComplexType>
@ificator and @BarryShehadeh It seems like the email property should be schematized.
Thank you for your answer. I was not clear but the issue is precisely about the email property being absent in the types and returned by the API. No problem with some properties being optional.
I also ran into this issue. Any updates on this?
I apologize, I somehow missed the previous notification from GitHub.
So there are two questions:
- Why is
idmissing? - Why is
emaila dynamic property instead of being present in the schema?
For the former it will be useful to understand the scenario - was this a call against SharePoint or OneDrive Personal? what API was being invoked?
For the latter - off the top of my head I don't see why this cannot be the case. There will be times when there is no email (e.g. if the identity represents a device) and so the value would be nullable but from that's essentially no different to todays state.
-
In my context, I'm using a SharePoint API. The exact same user sometimes has an
id, sometimes doesn't. Theemailproperty from that same user seems to be there most of the time, but not always. See also the scenario I posted here: https://github.com/microsoftgraph/microsoft-graph-docs-contrib/issues/4363. -
In the case that the
identityrepresents a device, it would also make sense to me that the email is nullable. However, (a) it is currently not documented (neither in the typings nor in the docs) and (b) it seems to be not consistently set for regular users as in my previous point.
Any kind of inconsistency should be viewed as a bug so we'll investigate what's going on with the delta API. Are there any other APIs that you've noticed missing id values?
Not that I know of, at the moment. Is there a better place to report those inconsistencies than the typings or docs repositories? Then I can report back there if I can consistently reproduce missing values using the Graph Explorer.
For OneDrive / SharePoint API issues / questions the best place is https://github.com/OneDrive/OneDrive-api-docs. We generally only spot issues other repos when we're explicitly tagged.
Hi @mpsijm we recently pushed a change that should result in delta populating the id for identity objects that represent a user/group. Could you confirm that things are looking more consistent for you now?
@ificator Yes, on first sight it looks like it's been fixed, thanks :smile: Still need to some more thorough testing, if I find anything weird I'll report back :slightly_smiling_face:
The email field now also seems to show up consistently in the response data (if the user has an email, of course), even though that field is still undocumented (see my second point in https://github.com/microsoftgraph/msgraph-typescript-typings/issues/116#issuecomment-716720698).
Hello @mpsijm , could you please tell me how do you make the email and id of a user showing up consistently in the response CreatedBy filed. MS Graph API is GET /drives/{drive-id}/items/{item-id} For some users, the email and id are missing in the response.
https://learn.microsoft.com/en-us/graph/api/resources/identity?view=graph-rest-1.0 In some circumstances, the unique identifier for the actor might not be available. In this case, the displayName property for the identity will be returned, but the id property will be missing from the resource. What is the circumstance?
@aigolang I did not do anything specific for this. The change in the API from https://github.com/microsoftgraph/msgraph-typescript-typings/issues/116#issuecomment-733835281 appeared to have fixed things, and we did not run into any issues since then. I still do not know under what circumstances some fields may be empty :sweat_smile: