According to the DOCs is the lastModifiedDateTime should be a valid parameter for the orderby :
"Comma-separated list of properties that are used to sort the order of items in the response collection. Works for name, size, and lastModifiedDateTime fields."
however, this request is failing:
https://graph.microsoft.com/v1.0/me/drive/root/children?orderby=lastModifiedDateTime desc
is this a bug? as it's working with the name
According to your description, you want to list the children item order by the ‘lastModifiedDatetime’.
Base on my test, It’s most likely a bug or by design. We can posted it on Microsoft User Voice to let developer know.
Related
When invoking either
GET /solutions/bookingBusinesses/{id}/calendarView
or
GET /solutions/bookingBusinesses/{id}/appointments
the returned bookingAppointment object has an empty customer array. However the customers appear in the UI. Any idea why this may be the case?
Looks like a bug in Graph API.
According to the documentation the customers property is optional. Sometimes you have to specify optional property in $select statement.
GET solutions/bookingBusinesses/{id}/calendarView?start=2018-04-30T00:00:00Z&end=2018-05-10T00:00:00Z&$select=customers
Another option is trying beta version instead of v1.0
GET beta/solutions/bookingBusinesses/{id}/calendarView?start=2018-04-30T00:00:00Z&end=2018-05-10T00:00:00Z
With a channel reporting job, we can get the end_screen_element_ids for a given video. These IDs look like GUIDs.
The question is : How do we query the Youtube API to get what video/channel/... these end_screen_element_ids points to ?
Thanks!
You may use the reportTypes.list method. This returns a list of report types that the channel or content owner can retrieve. Each item in the list contains an id property, which identifies the report's ID, and you need this value to schedule a reporting job.
I would like to query from Microsoft Graph all groups where a specific user is owner.
I tried the following query:
https://graph.microsoft.com/v1.0/groups?$filter=owners/any(owner: owner/id eq '4dc60fe7-8009-4131-a4e9-80dc5e86f98f')
Unfortunately this returns a 400.
Does anyone know the correct OData query? Or is this not even supported by MS Graph?
It's not possible to filter on owners. The documentation states which properties can be $filter'ed.
Look for
Supports $filter
in the description of each property.
You are going to have to read all groups, pull out their owners, and do the filtering client side.
The memberOf endpoint returns all the groups of a given user:
https://graph.microsoft.com/v1.0/users/{ID or email}/memberOf
Will return:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups",
"value": [
{
"id": "XXXX-XXXX-XXXX-XXXX",
"displayName": "The group name",
"...":"...",
}
]
}
It is possible to get all groups with owners using single API call like this:
https://graph.microsoft.com/v1.0/groups?$expand=owners
and then select groups which have current user in owners collection.
You could use List ownedObjects graph API to do that where it gets the list of directory objects that are owned by the user.
But as the question is specifically about getting the list of groups that a user is owner of, you can use the below graph API where it gets the list of directory objects with odata.type as microsoft.graph.group:
GET https://graph.microsoft.com/beta/users/{User Object ID}/ownedObjects/microsoft.graph.group
And if you just want to get the group name and group ID, you can use $select,
GET https://graph.microsoft.com/beta/users/{User Object ID}/ownedObjects/microsoft.graph.group?$select=displayName,id
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.
I'd like to list the appointments that a contacts is set to as a required participating party. I'm running the following query in my organization.
The service end point is set up like so.
https://bazinga/XRMServices/2011/OrganizationData.svc/AppointmentSet?
And then I concatenate that with the following.
$select=
ScheduledStart,
ModifiedOn,
appointment_activity_parties/PartyId
&$top=1000
&$filter=
ModifiedOn gt DateTime'2014-08-21'
&$expand=appointment_activity_parties
This gives me a list of a few appointments and when I investigate the contents, I can clearly see a tag called PartId with Id, Name etc. in it. The infromation is there. Then I check by hand the guid of the contact I'm curious about and add another condition in the filter specifying it.
$select=
ScheduledStart,
ModifiedOn,
appointment_activity_parties/PartyId
&$top=1000
&$filter=
(ModifiedOn gt DateTime'2014-08-21')
and (appointment_activity_parties/PartyId eq guid'...')
&$expand=appointment_activity_parties
However, the stupid organization service says that no property PartyId exists. When I try adding /Id, it says something about no support for complex data types when querying. I'm sure it's just a small syntax thingy but after a few hours and sick and tired. What do I miss?!
Your scenario behind the clause (appointment_activity_parties/PartyId eq guid'...') is that you want to find out appointments in the Appointmentset the PartyId of whose appointment_activity_parties equals a certain GUID. But you need to specify do you want to return the appointment if the PartyId of any of its appointment_activity_parties equals that GUID, or you want to return the appointment only when all of the PartyId of its appointment_activity_parties equals that GUID.
This any and all difference is specified in the section 5.1.1.2 of OData V4 Protocol part 2: URL Conventions.
Thus, you can rewrite your query as follows:
$select=
ScheduledStart,
ModifiedOn,
appointment_activity_parties/PartyId
&$top=1000
&$filter=
(ModifiedOn gt DateTime'2014-08-21')
and (appointment_activity_parties/any(a:a/PartyId eq guid'...'))
&$expand=appointment_activity_parties
And you can choose modify the any to all according to your actual needs.