What is the "Alternative Operator" to "Replace Multiple OR statement" in $Filter query of "Microsoft Graph API" - microsoft-graph-api

I need to find detail of more than 20 users in one query, so I am trying to use below query, But maximum 15 "or" is allowed in one query. So please let me know operator which I can use instead od using "multiple OR statement"
https://graph.microsoft.com/v1.0/users?$filter=startsWith(userPrincipalName, 'user1') or startsWith(userPrincipalName, 'user2').......

That's a per request threshold and I don't think it can be directly tackled with a drop-in replacement but here's some other ideas for you to consider:
1) If your application stores the user ids you can use the get directory objects by id endpoint which gets up to 1000 users back in one request https://learn.microsoft.com/en-us/graph/api/directoryobject-getbyids?view=graph-rest-1.0&tabs=http
2) Keep your current query but use MS Graph $batch requests to send multiple of these queries in one call to MS Graph. This will require you to construct the JSON batch payload and parse the response. https://learn.microsoft.com/en-us/graph/json-batching

Related

Filtering MS Graph query for Planner Tasks

I am querying ms graph for planner tasks https://graph.microsoft.com/v1.0/Planner/Plans/PlanID/tasks
This returns all the tasks in planner. I am hoping to filter these tasks by 'createdDateTime' greater than equals to last month. OR 'percentComplete' is less than 100.
New to querying data, so I am unsure what syntax to use. I was hoping to use $top= x would be based on createdDateTime. but if I use this
https://graph.microsoft.com/v1.0/Planner/Plans/planID/tasks?$Top=20
it still returns all of the tasks.
Thank you
Unfortunately, Planner doesn't support filters at this time. The recommended approach is for the client to read the data and filter on the client side.
For general filtering and query parameters, this documentation should help: https://learn.microsoft.com/en-us/graph/query-parameters?view=graph-rest-1.0

Filter out declined events

I need to use microsoft graph api, more in detail the calendar one, to retrieve some events of the users (up to 1000 entries).
I need to filter out the events that the user have declined.
That information is stored in the assignee resource, or conveniently in the 'responseStatus' property.
The issue that I'm having is that anytime I try to retrieve the assignee resource, the query takes 10x time to perform (from 1.2s without the assignees to 12-14s with).
(https://graph.microsoft.com/v1.0/me/events?select=id,subject,start,end,sensitivity,assignee&top=1000)
So i've tried to get the responseStatus instead and...guess what, the performance are always 10x worst (https://graph.microsoft.com/v1.0/me/events?select=id,subject,start,end,sensitivity,responseStatus&top=1000)
I've then decided to try to filter them directly (https://graph.microsoft.com/v1.0/me/events?select=id,subject,start,end,sensitivity,responseStatus&top=1000&filter=responseStatus/response ne 'declined') but I receive an error message stating that "The property 'responseStatus' does not support filtering."
And I'm having an hard time filtering the assignee resource.
So...is there a simple way to filter declined events without having such performance issues?
You can use the extended property pidlidresponsestatus https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/pidlidresponsestatus-canonical-property to filter those out eg
https://graph.microsoft.com/v1.0/me/events?$select=subject,body,bodyPreview,organizer,attendees,start,end,location,responsestatus&$filter=singleValueExtendedProperties/any(ep:ep/id eq 'Integer {00062002-0000-0000-C000-000000000046} Id 0x8218' and cast(ep/value, Edm.Int32) ne 4)

Querying JIRA to Produce Counts of Issues by Different Type

Suppose I have the following JIRA filter.
project = XXX AND resolution = Unresolved AND assignee in (EMPTY) ORDER BY Type asc, priority desc
I use it to see all unassigned issues in a certain project and pull from for triage.
Every now-and-then, I need to know how many are in each Type, i.e., I actually want a count for each.
How could I modify this query to do that or write a new one that accomplishes the same thing?
Remember that JQL isn't SQL - it just operates on tickets and returns lists of them for other parts of JIRA to consume, and doesn't really have a mechanism for counting results.
That said, you can use the JIRA REST API's /search endpoint along with maxResults=0 to construct JQL queries for each Type you care about, and the endpoint will give you a total value for that ticket Type:
https://jira.url/rest/api/latest/search?jql=project%20=%20XXX%20AND%20resolution%20=%20Unresolved%20AND%20assignee%20in%20%28EMPTY%29%20AND%20Type%20=%20Task&maxResults=0
Results in this output for Type=Task:
{
"startAt":0,
"maxResults":0,
"total":123,
"issues":[]
}

Microsoft Graph API using filter on get sharepoint lists

I'm trying to filter on the sharepoint lists, but the semantics seems to be different to the default semantics.
What I already tried was (with $ and without; single quotes and no quotes):
https://graph.microsoft.com/v1.0/sites/root/lists?filter=name eq 'Something'
https://graph.microsoft.com/v1.0/sites/root/lists?$filter=name eq 'Something'
https://graph.microsoft.com/v1.0/sites/root/lists?filter=id eq 'CFFF1460-B4D7-419C-A921-61B5279BBDDC'
https://graph.microsoft.com/v1.0/sites/root/lists?$filter=id eq 'CFFF1460-B4D7-419C-A921-61B5279BBDDC'
https://graph.microsoft.com/v1.0/sites/root/lists?filter=id eq CFFF1460-B4D7-419C-A921-61B5279BBDDC
https://graph.microsoft.com/v1.0/sites/root/lists?$filter=id eq CFFF1460-B4D7-419C-A921-61B5279BBDDC
But everything returns an array containing all lists and not only the subset matching the desired criteria.
So how can I filter on sharepoint lists?
If you know the id of the list you want to filter and get a response for.
YOu can run a graph API query like this.
https://graph.microsoft.com/v1.0/sites/root/lists/{list-id}
This will give you data about that list.
Let me know if you need further details on this.
Unfortunately (like Marc already mentioned in the comments) it is not possible to filter on SharePoint lists. If you need to, you have to do it on the client side, by reading the list without any filter and make a LINQ statement (or something similar) on the received collection. Be aware that (like all collections in Graph) you don't get always all elements at once. Potentially you have to call the next link request from the last response and wade through more requests and elements till you find what you need.
So when you found what you need, it is a good idea to store the list id within a memory cache or Redis cache for faster lookups the next time, you need this information.

Volusion API - Retrieve Daily Unprocessed Ordres

The answer to my question should be relatively simple - but I can't seem to find a simple answer. I'm trying to find a way to regularly connect to Volusion API to retrieve orders in a manner that assures no duplicates and no missing orders. However, because of the way that queries must be written I'm finding it difficult: 1) You can't use comparisons in queries (greater than, less than, etc.) and 2) The date fields require a full date/time with HHmmss. 3) There is a limit on the number of orders retrieved with each query. If you query against a date/time, for example, you usually can only get one order, because I can't use a comparative function. I saw one post here that suggested iterating through order ID's until no data is received. Has anyone found an easier way to accomplish order retrieval with Volusion API?

Resources