Outlook 365 Calendar API - Filter by Date - office365api

I am having some difficulties getting the $filter property of an Outlook 365 query working. Any advice is appreciated.
My query works flawlessly until I add $filter to it, then it returns nothing.
https://outlook.office.com/api/v2.0/Me/Events?$filter=Start/DateTime ge '2016-07-21T07:00:00'&$select=Subject,Start,End,Categories,ShowAs,Sensitivity&$orderby=Start/DateTime&$top=10
My goal is to pull my calendar entries for just today. Once I figure out why the Start/DatTime filter is not working I'll be adding End/DateTime to be the same day with a different end time
Thanks in advance for your help!

you have spaces in the query, replace them with %20

Related

How to apply multiple filters using Microsoft Graph API

I am new to using the Graph API and trying to use the beta version to get user information and want to filter based on userType and signInActivity/lastSignInDateTime. Individually the filters work fine on their own but together they error with a "filter not supported". This happens in the Graph Explorer also but the documentation indicates I should be able to filter on more than one thing? I can only think if it is a restriction of the signInActivity filter specifically that doesn't allow you to do another filter?
These both individually work:
https://graph.microsoft.com/beta/users?filter=userType eq 'Guest'&select=displayName,id
https://graph.microsoft.com/beta/users?filter=signInActivity/lastSignInDateTime ge 2021-05-01T00:00:00Z&select=displayName,id
However the following does not work and returns a "Filter not supported" error:
https://graph.microsoft.com/beta/users?filter=signInActivity/lastSignInDateTime ge 2021-05-01T00:00:00Z and userType eq 'Guest'&select=displayName,id
Any help would be appreciated!
I see a similar question was asked here Microsoft Graph - Error when using multiple filters for CalendarView but no answer currently.
I found the answer to this -- basically, to add multiple clauses to your $filter, simply add the word "and" to separate each criteria. this is the example I used and it seemed to work quite well:
https://graph.microsoft.com/beta/users?$count=true&$filter=endsWith(userPrincipalName,'mydomain.com') and accountEnabled eq false&$orderBy=userPrincipalName&$select=id,displayName,userPrincipalName,department,employeeid,jobtitle,accountEnabled
as it turns out, odata seems to not worry too much about spaces.
Those 2 filter types cannot be combined as of today.
I suggest pulling the data based on login and then reduce the list of last login down to Guests
- set_fact:
foo: "{{ bar | selectattr('userType', '==', 'Guest') | list }}"
On a sidenote: Thank you #soler - your answer helped me realize where I was screwing up a different filter statement.
replacing spaces by %20 is working for me:
$filter=UserType%20eq%20'Guest'and%20signInActivity/lastSignInDateTime%20le%202021-04-26T17:30:09Z
Found this post as I had the same issue.. adding the filter statement twice worked for me https://graph.microsoft.com/beta/users?$count=true&$filter=UserType eq 'Guest'&$filter=signInActivity/lastSignInDateTime le 2021-04-26T17:30:09Z&$select=displayName,UserType,signInActivity

Using period / dot when searching users by email on Microsoft Graph API and ODATA return no results

I'm using Microsoft Graph API to get all users from my directory that have their email address starting with a given value.
All is working well except when my value contains a period / dot. In this case, the Graph API returns no result.
How can I search all users with their email starting by a given value containing a period / dot.
Here's an example.
The following request works fine:
https://graph.microsoft.com/v1.0/users?$filter=startsWith(displayName, 'john')
The following request (containing a dot in the odata query) returns no results
https://graph.microsoft.com/v1.0/users?$filter=startsWith(displayName, 'john.d')
I already tried to encode the dot / period with %2E and it does not work:
https://graph.microsoft.com/v1.0/users?$filter=startsWith(displayName, 'john%2ed')
Does anybody know how I can do that ?
Thanks !
Based on my test, dot should work in this filter query.
If we want to search the users by email. we could $filter the field mail not the field displayName.
https://graph.microsoft.com/v1.0/users?$filter=startsWith(mail, 'john.d')

Filtering Groups by createdDateTime

I`m trying to filter Office 365 Groups based on their creation time using Microsoft Graph.
Unfortunately, all DateTime formats produce a 400 - BadRequest - Invalid filter clause response.
I tried below filter clauses:
/v1.0/groups?$filter=createdDateTime/DateTime gt 2016-10-24T14:21:03.000Z
/v1.0/groups?$filter=createdDateTime gt '2016-10-24T14:21:03.000Z'
Could you please help me out on what I`m missing?
I'm afraid Groups do not support filtering by createdDateTime or gt today.
If you would like to see this added to Microsoft Graph, you can submit this idea to Microsoft Graph's UserVocie.

Is there anyway to retrieve ALL tweets from twitter for the past x time (or how to stream all new real-time tweets)?

I'm trying to try to retrieve ALL tweets for an x time interval.
For example, I want to try to get all the tweets posted in the past 5 seconds (no specific word search in the query) - how would I be able to do this? I tried searching twitter documentation for a solution using the REST/Search/Streaming API but I've had no luck. I tried searching for an empty string as my query, but I get an invalid input as my response.
If anybody has any idea on how to do this it would be greatly appreciated.
Thanks

Find WorkItems that were assigned to X in the last 30 days

I'm trying to find all WorkItems that were assigned to a person X in the last 30 days.
The big problem I have is the "in the last 30 days"-part.
I thought about using the "ever" or "asof" keywords, but couldn't find a good answer yet.. something like WHERE [Assigned To] = 'X' AND (([Assigned To] != 'X') asof '<30daysago>').
But this is still not a bulletproof solution.
Any better ideas?
Thanks & kind regards
Simon
It appears that this is not possible using just WIQL, but you can get close.
The keyword #Today will give you today's date, then just subtract your range from it. The EVER keyword applied to [Status]='AssignedTo' and a comparison against a date 30 days in the past to [StateChangeDate] is what you'll need to accomplish this.
As close as you can get with WIQL and existing fields:
This says, from all revisions (status changes) return records where the user 'X' has ever been AssignedTo and the State has changed in the last 30 days. This will basically give you a slightly fuzzy picture of what your User has been working on in the last month.
WHERE [Microsoft.VSTS.Common.StateChangeDate] >= #today - 30
AND [System.AssignedTo] EVER 'Bennett Aaron'
ORDER BY [System.State]
Add the missing field:
You could add a custom field called AssignedDate that is captured during the New->AssignedTo workflow transition that you create in the Work Item Definition XML. You can accomplish this using the Team Foundation Server Power Tools extension to Visual Studio. This would give you exactly what you need as well as additional reporting options going forward.
TFS API
I cannot help you with this one, but I believe you could query using the TFS API.
A couple of quick gotchas I've experienced to save you time on ASOF and EVER:
AsOf won't help you by itself with this as it does not support a range of dates. It allows you to query as if it were another date. In other words, if you forgot to capture the results of a query yesterday, you can use an AsOf query to get the results that you would have gotten had it run yesterday. What I understand is that you want to query a basic date range.
EVER might not work as you expect against dates as I believe it uses the exact value of the field (timestamp portion of the date field would be included) it tests with. Just make sure the EVER keyword is used against the status field rather than a date.

Resources