Unable to expand MemberOf using Microsoft Graph .NET SDK using Delta Query - microsoft-graph-api

Expanding properties doesn't seem to work when using Delta queries. It works fine with regular user query.
Is this a limitation in Microsoft Graph API?
var usersInfo = graphServiceClientWithApplicationPermission.Users.Delta().Request().Expand("MemberOf").GetAsync();
// Add inital request users
foreach (var userInfo in usersInfo)
{
// Member info doesn't seem to be expanded even if $expand=MemberOf is sent
if (userInfo.MemberOf == null)
{
userInfo.MemberOf = await applicationPermissionsClient.Users[userInfo.Id].MemberOf.Request().GetAsync();
}
// MemberOf is now populated ??
}

Seems like this is another limitation of the Microsoft Graph and not supported.
Optional query parameters
If a client uses a query parameter, it must be specified in the
initial request. Microsoft Graph automatically encodes the specified
parameter into the nextLink or deltaLink provided in the response. The
calling application only needs to specify their desired query
parameters once upfront. Microsoft Graph adds the specified parameters
automatically for all subsequent requests. For users and groups, t
here are restrictions on using some query parameters:
If a $select query parameter is used, the parameter indicates that the
client prefers to only track changes on the properties or
relationships specified in the $select statement. If a change occurs
to a property that is not selected, the resource for which that
property changed does not appear in the delta response after a
subsequent request. $expand is not supported.
For users and groups beta (preview) APIs, scoping filters allow you to
track changes to one or more specific users or groups by objectId. For
example, the following request:
https://graph.microsoft.com/beta/groups/delta/?$filter= id eq
'477e9fc6-5de7-4406-bb2a-7e5c83c9ae5f' or id eq
'004d6a07-fe70-4b92-add5-e6e37b8acd8e' returns changes for the groups
matching the ids specified in the query filter.
https://developer.microsoft.com/en-us/graph/docs/concepts/delta_query_overview

Related

Microsoft Graph API DeltaLinks for Mailbox messages Not Returning Minimal Data on Changes

Delta query on users returns minimal data on changes using the header (Prefer Return = minimal).
Graph Explorer : https://graph.microsoft.com/v1.0/users/delta
C# : await graphClient.Users.Request().GetAsync();
But in the case of mailbox messages it returns all parameter, although using the header (Prefer Return = minimal).
Graph Explorer : https://graph.microsoft.com/v1.0/users/userid/mailFolders/inbox/messages/delta
C# : await graphClient.Users[userId].MailFolders[folderId].Messages.Delta().Request().GetAsync();
Is there any way to get the minimal data on mailbox message changes with delta query?
The Message delta documentation only defines a header for limiting the page size:
Each delta query GET request returns a collection of one or more messages in the response. You can optionally specify the request header, Prefer: odata.maxpagesize={x}, to set the maximum number of messages in a response.
If you want to track a specific set of properties, you can limit the response using the $Select query parameter:
You can use a $select query parameter as in any GET request to specify only the properties your need for best performance. The id property is always returned.
Only AAD resources support the Prefer: return=minimal header.

Changing location of $top clause in OData query changes results when Querying MSAX7

I have an ODATA query that pulls the first record from the Dynamics AX table and ignores the $filter clause when the $top parameter is the first parameter. However, it pulls the correct record for the $filter clause when the $top parameter is at the end of the query.
Question: How do I make the OData server honor the full query no matter where the $top parameter is placed?
the following two cases return identical results:
Case 1: https://url/data/Users?$top=1
{
"#odata.context":"https://url/data/$metadata#Users","value":[
{
"#odata.etag":"W/\"J5zEx4NDg33OD2YyM4TEs5NTY6zNz7E0ND7U3Nic=\"",
"Id":"first_user_in_the_table",
"Alias":"first_user_in_the_table#domain.com",
"Name":"first_user_in_the_table"
}
]
}
Case 2: https://url/data/Users?$top=1&$filter=Alias%20eq%20%27specific_user#domain.com%27
{
"#odata.context":"https://url/data/$metadata#Users","value":[
{
"#odata.etag":"W/\"J5zEx4NDg33OD2YyM4TEs5NTY6zNz7E0ND7U3Nic=\"",
"Id":"first_user_in_the_table",
"Alias":"first_user_in_the_table#domain.com",
"Name":"first_user_in_the_table"
}
]
}
However, when I move the $top parameter to the end of the query string I get the correct result.
Case 3: https://url/data/Users?$filter=Alias%20eq%20%27specific_user#domain.com%27&$top=1
{
"#odata.context":"https://url/data/$metadata#Users","value":[
{
"#odata.etag":"W/\"Jz3kz4Nj5g2N6zcz7MCw81Nj9M3M2TU3w4NT4c54Jw==\"",
"Id":"specific_user",
"Alias":"specific_user#domain.com",
"Name":"The Specific User I Actually Want"
}
]
}
As far as I understand the OData specification, this is incorrect behavior. I base this on 11.2 Requesting Data which states that the $top query option should be evaluated last and after the $filter query option. Also section 2. Query Options of the OData ABNF construction rules seems to indicate that the query options may appear in any order in the URL.
This indicates that this particular behavior may have been incorrectly implemented. You will probably not be able to solve this short of implementing a custom service that wraps the existing one to reorder the query options as needed. I would also assume that this impacts the behavior of all Odata services.
I suggest you create a support request with Microsoft so they can adress this.

Select=*,PropertyName does not return the value for the PropertyName in Microsoft Graph api

In Graph Explorer if i make a request to:
/v1.0/users/[User.Id]/drive/root/children?$select=*,sharepointIds
I do not get back the sharepointIds property from MS Graph.
If I remove * from select query parameter and only request sharepointIds property then I get the sharepointIds property and its values.
v1.0/users/[User.Id]/drive/root/children?$select=sharepointIds
I would expect $select=*,sharepointIds to return both the default properties and the sharepointIds in the same response.
Is there another working way for the clients to request additional properties from Microsoft Graph without typing all of the property names in the object one by one including the default properties?
The underlying OneDrive API seems to handle select=*,[propertyName] correctly.
This isn't possible today. Microsoft Graph currently doesn't support wildcards in a $select query parameter. Each property you want to return must be explicitly listed in the $select.

How to get the last inserted row via Odata service

Update:
Using ODATA, How to get the last inserted row in /MySet where MySet.Name = "abc".
I do not want to continuously poll the odata service via model.read(). I know attachChange() or attachDataReceived()methods can be use to get notified automaically. But apart from notification, how to get the 'inserted row'. Also My doubt is how to satisfy the following three conditions here : $top=1, $orderby= Date desc and $filter=NAME eq 'ABC'
The only solution I can think of is to get notified by data inserted via attachDataReceived() and then make a model.read() call with the required filters and additional parameters. Although this would result in these additional 'read' calls.
Original Post Below:
Question: How to pass filters in element binding?
Post: I am using odata service for populating my views.
I want to pass certain filters like $filter=NAME eq 'Scott'
Since I want these parameters to be included only when with odata request for a specific ui-element, I want to include them in bindElement()
specifically something like this
var myFilter = new Array();
myFilter.push(new sap.ui.model.Filter("NAME", sap.ui.model.FilterOperator.EQ, 'Scott'));
var myStandardTile = this.byId("__tile3");
myStandardTile .bindElement("/MySet",{filters:myFilter});
But unfortunately this does not works. When I see the 'network' tab in developer console, Filters are not being added with my request.
You cannot. Neither filter nor sorter nor formatter are supported by element bindings. They are only supported by list and tree bindings.

Getting some data from Microsoft Graph unified OData endpoint

How to count number of items in EntitySet of MicrosoftGraph, for example 'users' or 'groups'? I tried:
https://graph.microsoft.com/v1.0/users?$count
Returns: lists all users
https://graph.microsoft.com/v1.0/users/$count
Returns:
{ "error": { "code": "Request_BadRequest", "message": "Unexpected segment Edm.Int32.", } }
Also in Annotations of target "microsoft.graph.directoryObject" which are those EntitySets based on I see that it is Selectable=false, Countable=false ...
Will $skip be ever available on 'users' or other toplevel EntitySet items ( https://graph.microsoft.com/v1.0/groups?$skip=5 ) ? It is available on other items ( https://graph.microsoft.com/v1.0/me/contacts?$skip=5 ). I know about $skipToken, but it is not the same.
Can I find somewhere in the $metadata if property is sortable? For example user.displayName is sortable, but user.mail or user.givenName are not. This would be handy in the $metadata. Is there plan to introduce this into $metadata?
OrderBy DESC in this formula https://graph.microsoft.com/v1.0/users?$orderBy=displayName%20desc is ignored, it shows items ordered ASC, am I doing something wrong?
Not much help I know, but if you do an API call that gets a Collection you can get a count using the second form you gave in the first question. Eg:
https://graph.microsoft.com/v1.0/users/<id>/events/$count
returns the count (6 in my case, and not in JSON - the returned data is actually "\x{ef}\x{bb}\x{bf}6" (in Perl formatting)). If we use the ? as the last separator (which is what http://graph.microsoft.io/en-us/docs/overview/query_parameters seems to indicate we should) with this URL:
https://graph.microsoft.com/v1.0/users/<id>/events?$count
I just get the list of events with no count as you do.
So that seems to indicate two things to me:
a) The $count doesn't appear to work as a query parameter, despite the documentation and the OData standards saying it should,
and
b) There seems to be a bug in the API for handling EntitySets which isn't there for Collections.
Sorry I can't be of more help, but its another data point at least (I just came unstuck with the same thing which is why I noticed this StackOverflow post!)
Ad 1. https://graph.microsoft.com/v1.0/users/$count is the correct OData syntax (http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complete.html#_Toc406398087), but as indicated in the metadata directoryObject collections are not currently countable. ODataV4 also allows $count in query parameters (http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complete.html#_Toc406398166), but then it should be specified with true or false value (e.g. https://graph.microsoft.com/v1.0/me/events?$count=true) and the response will include both the collection and its count in the #odata.count property. This is again not supported for directoryObject collections.
Ad 2. There is no plan right now to support $skip for directoryObject collections.
Ad 3. Yes, we plan to indicate which properties are sortable by in metadata using the SortRestrictions annotation defined in the OData capabilities vocabulary (http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/vocabularies/Org.OData.Capabilities.V1.xml)
Ad 4. Your request is correct, but we only support sorting users by displayName in the ascending order.

Resources