I am trying to filter using single-value extended properties, according to the documentation:
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/singlevaluelegacyextendedproperty_get
I have a calendar with a large number of events (around 40k events). Each event has a property called 'ExpedienteId', and I am trying to filter by this property as follows:
https://graph.microsoft.com:443/v1.0/users/myuser#mytenant.onmicrosoft.com/calendars/CALENDARID/events?$filter=singleValueExtendedProperties/Any(ep: ep/id eq 'String {e363423c-3db9-4cf1-b2bf-3777d331d5e7} Name ExpedienteId' and ep/value eq '6313')
The first time I execute the request, I get this result:
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "a848a095-983a-460e-a9bf-4089b22aa485",
"date": "2017-10-18T12:47:07"
}
}
}
with a 503 Service Unavailable.
However, the second time I execute the request, I received the right results (filtered) almost immediately (It looks like the query has been cached).
What is wrong with the first call? Is there any limitation for this type of filter?
Related
According to the MS Graph API documentation, businessPhones are supported to be used in a $filter query with eq comparison, just like the imAddresses property.
When inspecting Microsoft's use query parameters documentation, there's an example where the imAddresses property is used in a collection filter and it works just fine.
GET https://graph.microsoft.com/v1.0/users?$filter=imAddresses/any(s:s eq 'admin#contoso.com')
My goal ist to list all users that have a specific phone number in their businessPhones collection property.
However, when I try to use the businessPhones property in a similar query, the query does not work as expected.
GET https://graph.microsoft.com/v1.0/users?$filter=businessPhones/any(s:s eq '1234')
Status code: 400
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'businessPhones' of resource 'User'.",
"innerError": {
"date": "2021-07-30T08:07:24",
"request-id": "ac3923be-de11-448f-b2b5-245edc82d20e",
"client-request-id": "ac3923be-de11-448f-b2b5-245edc82d20e"
}
}
}
Any ideas on what I am missing?
You need to use advanced query capabilities, which means you need to add a $count=true query string parameter and a ConsistencyLevel=Eventual header to your request.
I'm trying to get a list of SharePoint items using Graph API with a Filter clause, but I get an error when I specify a function such as StartsWith.
The following page says, "Support for the $filter operator varies depending on the Microsoft Graph API. Commonly supported are the following logical operators." Is it possible to use them?
https://learn.microsoft.com/en-us/graph/query-parameters#filter-parameter
■In the case of eq, data can be retrieved
/sites/{site-id}/lists/{list-id}/items?$expand=fields&$filter=fields/Title eq 'test'
■In the case of startsWith, an error will occur saying it is an invalid filter clause.
/sites/{site-id}/lists/{list-id}/items?$expand=fields&$filter=fields/Title startsWith 'test'
ErrorMessage :
{
"error": {
"code": "BadRequest",
"message": "Invalid filter clause",
"innerError": {
"date": "2021-07-13T02:09:30",
"request-id": "5f84935b-59f1-46cf-a160-18d64e989eb7",
"client-request-id": "e417c442-123d-ba3b-1465-8ff7f4f78645"
}
}
}
You should specify startswith in your Graph API URL as :
$filter=startswith(fields/Title,'test')
trying to add extended properties to calendar objects. I am able to create calendars with the following payload (Ruby syntax, payload is sent as a JSON):
name: build_calendar_name,
singleValueExtendedProperties: [{
id: "String {#{SecureRandom.uuid}} Name setting_id",
value: #setting_id.to_s
}]
I receive a 201 from this request and the calendar is created no problem
The frustrating part is I cannot retrieve the extended property when making a GET request. The following two requests should work:
GET /me/events/calendar_id?$expand=singleValueExtendedProperties($filter=id eq 'String {guuid} Name setting_id')
Response
{
"error": {
"code": "BadRequest",
"message": "Parsing OData Select and Expand failed: Found an unbalanced bracket expression.",
"innerError": {
"date": "2020-07-01T22:38:14",
"request-id": "<hidden>"
}
}
}
GET /me/calendars?$filter=singleValueExtendedProperties/Any(ep: ep/id eq 'String {guuid} Name setting_id' and ep/value eq 'setting_id')
Response:
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"date": "2020-07-01T22:40:15",
"request-id": "<hidden>"
}
}
}
Guuid, calendar_id and setting_id are dummy values, real values are used when attempting these calls.
We've also tried following the examples verbatim at this link https://learn.microsoft.com/en-us/graph/api/singlevaluelegacyextendedproperty-get?view=graph-rest-1.0&tabs=http#example and still receive these response codes. Would love some help with this. Thanks!
I reproduced this for the $expand case in Graph Explorer. The problem seems to be the = inside the parentheses. If you URL-encode that to %3D the query works fine.
$expand=singleValueExtendedProperties($filter%3Did eq 'String {guuid} Name setting_id')
For the $filter, I reproduce it when doing GET /me/calendars, but not when doing GET /me/events. This seems to be a problem with the service (unless the docs are just wrong). Let me check and report back.
I'm trying to $expand on singleValueExtendedProperties for a delta query on my messages, but I'm getting an odd error.
Delta query
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages/delta?$expand=singleValueExtendedProperties($filter=id eq 'String 0x007D')
Response
{
"error": {
"code": "InternalServerError",
"message": "Value cannot be null.\r\nParameter name: type",
"innerError": {
"request-id": "d7cf6c83-a062-4051-85b4-30a5aadf2e65",
"date": "2017-10-06T10:05:10"
}
}
}
The documentation says this is supported. I've also verified (via the GraphAPI explorer) that:
the non-delta version of the query works with singleValueExtendedProperties
the delta version works without singleValueExtendedProperties
Is this a bug in the API or expected behavior? I know I can follow up with multiples GETs to pull the desired extended properties, but I'd rather avoid spawning several requests if I can get away with one.
There is limited support for the $filter query parameter on messages/delta. From the documentation:
The only supported $filter expresssions are $filter=receivedDateTime+ge+{value} or $filter=receivedDateTime+gt+{value}.
This question is a follow-up to Get custom property set in Outlook Add-In via Microsoft Graph.
My Outlook Office.js add-in is adding some custom properties to an event. It works as expected and I can access those properties using Microsoft Graph, with following GET request:
/v1.0/me/events/{event-id}?$expand=SingleValueExtendedProperties($filter=id%20eq%20'String%20{00020329-0000-0000-C000-000000000046}%20Name%20cecp-b7ff386a-234a-4a38-84bc-e5ae4684b7af')
But now I try to subscribe to push notifications by posting such body to the push notifications endpoint (/v1.0/subscriptions):
{
changeType: "created,updated,deleted",
notificationUrl: `[...my url...]`,
resource: `/users/${userData.id}/events?$filter=singleValueExtendedProperties/any(ep%3A%20ep%2Fid%20eq%20'String%20{00020329-0000-0000-C000-000000000046}%20Name%20cecp-b7ff386a-234a-4a38-84bc-e5ae4684b7af')`,
expirationDateTime: tomorrow,
clientState: "SecretClientState"
}
But I'm getting:
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: BadRequest; Reason: Bad Request]",
"innerError": {
"request-id": "01dcece6-0103-4bef-8231-e9ab9480402a",
"date": "2017-04-04T20:20:58"
}
}
}
Tried to set the resource in the request unescaped, but with same result, next thing I tried is the $filter functionality, so did a get request in following format using the MS Graph explorer:
/v1.0/me/events/?$filter=singleValueExtendedProperties/any(ep%3A%20ep%2Fid%20eq%20'String%20{00020329-0000-0000-C000-000000000046}%20Name%20cecp-b7ff386a-234a-4a38-84bc-e5ae4684b7af')
but got following error:
{
"error": {
"code": "ErrorInvalidUrlQueryFilter",
"message": "The filter expression for $filter does not match to a single extended property and a value restriction.",
"innerError": {
"request-id": "aca7c8ed-6e30-4490-8feb-7f1d2aed6b88",
"date": "2017-04-04T20:38:28"
}
}
}
does it mean that I also have to filter by value and not only id?
That would be an issue because I want the events that have the property set, but I don't know the value beforehand, I want to read it after I get a push notification.
Is there a way to get events which simply have a custom property set by my add-in, and subscribe to push notifications for events which has this custom property?
EDIT:
When I change id to PropertyId as suggested in the answer I'm getting:
{
"error": {
"code": "BadRequest",
"message": "Could not find a property named 'PropertyId' on type 'microsoft.graph.singleValueLegacyExtendedProperty'.",
"innerError": {
"request-id": "1d3db71e-6ee2-4680-9317-64687813c52a",
"date": "2017-04-05T13:49:45"
}
}
}
EDIT-2:
Now when I add filtering by value, it works:
/v1.0/me/events/?$filter=singleValueExtendedProperties/any(ep: ep/id eq 'String {00020329-0000-0000-C000-000000000046} Name cecp-b7ff386a-234a-4a38-84bc-e5ae4684b7af' and ep/value eq 'foo')
but I wan't all the events with that property regardless the value of it...
EDIT-3
No trying by filtering by value but using the non-equal ne operator:
/v1.0/me/events/?$filter=singleValueExtendedProperties/any(ep: ep/id eq 'String {00020329-0000-0000-C000-000000000046} Name cecp-b7ff386a-234a-4a38-84bc-e5ae4684b7af' and ep/value ne 'Foo')
it seems to work, but this time it looks like it just ignores the filter and returns all events, with and without that custom property set from the add-in.
After several tries I found a way to filter for events/messages that have a custom property regardless it's value:
https://graph.microsoft.com/v1.0/me/events/?$filter=singleValueExtendedProperties/any(ep: ep/id eq 'String {00020329-0000-0000-C000-000000000046} Name cecp-b7ff386a-234a-4a38-84bc-e5ae4684b7af' and ep/value ne null)
with the added important part being and ep/value ne null, whereas something like and ep/value ne 'fooo' didn't work, it just returned everything.
Above filtering works also for filtering of events for which we want subscribe to push events.
I believe the filter query should be
PropertyId eq ....
instead of Id eq ...