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.
Related
I'm trying to use the Teams Export API to export a single Teams channel. I have my permissions set up properly; if I make a request to
https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages (without specifying a filter), I get the paginated results of all of the channel messages on my team. If I copy the sample datetime filters in that documentation, I also get a successful response with the appropriate results.
A successful response gives me a list of messages. Each one shows a channelIdentity field, which contains a channelId (fields removed for readability):
{
"value": [
{
"channelIdentity": {
"teamId": "{TEAM ID}",
"channelId": "{CHANNEL ID}"
},
},
]
}
What I want is to use this channelIdentity/channelId field as a filter on the results, so that I can export just the messages from a single channel.
If I run GET https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages?$filter=channelIdentity/channelId eq '{CHANNEL ID}', I get an error:
{
"error": {
"code": "BadRequest",
"message": "The entity property 'channelIdentity/channelId' and operationKind 'Equal' is not allowed in $filter query.",
"innerError": {
"date": "2022-11-16T23:47:06",
"request-id": "...",
"client-request-id": "..."
}
}
}
This reads to me like I'm not allowed to use eq with this ID. If I try a 'starts with', I get a different error:
GET https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages?$filter=startswith(channelIdentity/teamId, '{CHANNEL ID}')
{
"error": {
"code": "BadRequest",
"message": "Only binary operation expressions are allowed.",
"innerError": {
"date": "2022-11-17T00:11:26",
"request-id": "...",
"client-request-id": "..."
}
}
}
I'm unclear on what this is trying to say - either the ID starts with that phrase or it doesn't; it seems like a binary expression to me.
Is there some other approach I should use to get these results filtered by channel ID?
This API is designed to export everything from a team for backup/archival scenario. So, filtering by a specific channel is not supported now.
If you wish you may suggest this feature on Microsoft Feedback portal.
Any reason why you don't use List Channel Messages?
You can then make a GET call against this URL:
"https://graph.microsoft.com/v1.0/teams/{teamid}/channels/{channel id}/messages"
Note - as per that link you will need to Request access:
https://learn.microsoft.com/en-us/graph/teams-protected-apis
One other method, if you are using Graph Explorer, is add the signed-in user to the team as an owner, and it will let you test this method, you just won't be able to call via an App Registration until you do fill out that form.
Got error with call: /sites?select=siteCollection,webUrl&filter=siteCollection/root%20ne%20null
"error": {
"code": "invalidRequest",
"message": "Cannot enumerate sites",
"innerError": {
"request-id": "f73vvv65-d20e-xxx-ae30-829d46a981d6",
"date": "2019-10-24T17:17:03"
}
}
I strongly recommend you to go through this link. There is a typo with the request you are trying to make. $select and $filter are query options and hence, you'll have to use the following endpoint to obtain the desired result.
GET https://graph.microsoft.com/beta/sites?$select=siteCollection,webUrl&$filter=siteCollection/root%20ne%20null
Observe carefully that there is a $ sign before the filter query option.
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?
I called the endpoint /shares/{shareId} using msgraph-sdk-php, but got response 400 as:
{
"#odata.context":"https://graph.microsoft.com/v1.0/$metadata#shares/$entity",
"id":"s!here-is-the-share-id",
"name#odata.type":"#String",
"name":{
"error": {
"code": "BadRequest",
"message": "A primitive value was specified; however, a value of the non-primitive type '' was expected.",
"innerError": {
"request-id": "3ea56b1c-acd6-4fdf-a856-c46b35e01cb7",
"date": "2017-05-25T05:26:23"
}
}
}
(Yes, I even got 4 left brackets but only 3 right brackets.)
while I can get correct response via api.onedrive.com api with the same shareId.
I really can't find any tips from documentation.
Thanks for letting us know about this #SevenOutman! This was a configuration issue that has now been resolved.
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 ...