Using OR in filters for Office 365 Service Communications API or filtering by multiple IDs - office365api

How can I filter by multiple IDs using the Office 365 Service Communications API?
I'm getting the current status using https://manage.office.com/api/v1.0/{tenent}/ServiceComms/CurrentStatus which gives me incident IDs. I'm trying to use those IDs to get the messages affiliated but the message endpoint /ServiceComms/Messages is not working well with the filters.
The documentation shows:
I've tried:
/ServiceComms/Messages?ID=CR555555,/ServiceComms/Messages?ID='CR555555', /ServiceComms/Messages?Id=CR555555,/ServiceComms/Messages?Id='CR555555' - Returns everything (doesn't filter)
/ServiceComms/Messages?$filter=ID eq 'CR555555' - Returns Error
/ServiceComms/Messages?$filter=Id eq 'CR555555' - Returns 1 result
/ServiceComms/Messages?$filter=Id eq 'CR555555' or Id eq 'CR555556' - Returns error
I was able to get an AND result using
$filter=MessageType eq Microsoft.Office365ServiceComms.ExposedContracts.MessageType'Incident' and EndTime ge 2019-07-25T00:00:00Z but OR always errors with the message "Filter {filter} is invalid. Expected '<Item> <operator> <Value>' pattern."

You need to use Microsoft.Office365ServiceComms.ExposedContracts.MessageType'Incident' as your MessageType.
A request to /Messages should return you a odata context at the top of the response. For example:
{
"#odata.context": "https://office365servicecomms-prod.cloudapp.net/api/v1.0/{{TenantID}}/$metadata#Messages",
...
}
If you query that, you receive the metadata along with the possible filters. I cannot give you an example as of today (2020-02-16) a query returns a 500 Internal Server Error. Microsoft is working on a fix. Maybe it works again by the time you read my reply.
Complete example:
https://manage.office.com/api/v1.0/{{TenantID}}/ServiceComms/Messages?$filter=MessageType eq Microsoft.Office365ServiceComms.ExposedContracts.MessageType'Incident' and LastUpdatedTime ge 2020-02-13T00:00:00.000Z
And yes, the ID filter must be written 'Id'. Microsofts documentation has a lot of wrong information in it.

Related

Slack Conversations API conversations.kick returning "channel_not_found" for a public channel

I am writing a Slack integration that can boot certain users out of public channels when certain conditions are met. I have added several OAuth scopes to the bot token, including the following:
channels:history
channels:manage
channels:read
chat:write
chat:write.public
groups:write
im:write
mpim:write
users:read
I am writing my bot in Python using the slack-bolt library and asyncio. However when I try to invoke this code:
await app.client.conversations_kick(channel=channel_id, user=user_id)
I get the following error:
slack_sdk.errors.SlackApiError: The request to the Slack API failed. (url: https://www.slack.com/api/conversations.kick)
The server responded with: {'ok': False, 'error': 'channel_not_found'}
I know for a fact that both the channel_id and user_id arguments I'm passing in are valid. The channel ID I'm using is the string C01PAE3DB0A. I know it is valid because I can use the very same value for channel_id in the following API call:
response = await app.client.conversations_info(channel=channel_id)
And when I call conversations_info like that I get all of the information about my channel. (The same is true for calling users_info with the user_id - it returns successfully.) So why is that when I pass my valid channel_id parameter to conversations_kick I consistently receive this channel_not_found error? What am I missing?
So I got in touch directly with Slack support about this and they confirmed that there is a bug on their end. Specifically, the bug is that I should have received a restricted_action error response instead of a channel_not_found response. Apparently this is a known issue that is on their backlog.
The reason the API call would (try to) return this restricted_action error is simply because there is a workspace setting that, by default, prevents non-admins from kicking people out of public channels. Furthermore, this setting can only be changed by the workspace owner - one tier above admins.
But assuming you are the owner of the Slack workspace, you simply have to log into the Settings & Permissions page, which should look something like this:
And then you have to change the setting labeled "People who can remove members from public channels" from "Workspace admins and owners only (default)" to "Everyone, except guests."
Once I made that change, my API calls started succeeding.

get In-Reply-To value from InternetMessageHeader in outlook graph api

I'm trying to use the MS graph API to get the In-Reply-To message header without having to return the entire header (internetMessageHeaders). I already get several properties (such as bccRecipients, from, id) which are documented here
I've seen several SO questions asking this and they point to using SingleValueExtendedProperties/internetMessageHeaders with a $filter clause. I've tried this and it appears to only work with properties which are documented
This is what I've tried all give a 404 error (i've checked the the In-Reply-To header is present on the actual message)
https://graph.microsoft.com/v1.0/me/messages/MSG_ID?
$select=Subject,internetMessageId,from,id,bccRecipients,
SingleValueExtendedProperties&$expand=SingleValueExtendedProperties($filter=In-Reply-To eq 'String 0x007D')
https://graph.microsoft.com/v1.0/me/messages/MSG_ID?
$select=Subject,internetMessageId,from,id,bccRecipients,
internetMessageHeaders&$expand=SingleValueExtendedProperties($filter=In-Reply-To eq 'String 0x007D')
https://graph.microsoft.com/v1.0/me/messages/MSG_ID?
$select=Subject,internetMessageId,from,id,bccRecipients,
internetMessageHeaders&$expand=internetMessageHeaders($filter=In-Reply-To eq 'String 0x007D')
You need to request PR_IN_REPLY_TO_ID MAPI property (0x1042001F)
$expand=singleValueExtendedProperties($filter=id eq 'String 0x1042')

What's the max possible length of an id list that can be sent to YT video API?

I call YT.Channel API with a list of Ids and I get an error:
GoogleJsonResponseException: API call to youtube.channels.list failed with error: Request contains an invalid argument.
YouTube.Channels.list('id, snippet, statistics', {
id: resultsParentChannelIdsPerPage.join()
}).getItems()
id = UC5JU3rLOMvB7ZIXI2oi1ubg,UC4mKtxAtWQgmkFC6S6siNVg,UC-4hR9ralZoAW15tAwSbJ_A,UCvdwiASqQrIIozQcVAXvRXw,UCUIKx2bIjRcBWyIa3AQGSCg,UClkJAMCknefAzrYfpk1_0Nw,UCsDm3gAWuDRDLMjZLoUxOuA,UC-OkSUXpLrS2eBpztAJ78wg,UCb6RivygioXGs0icq4McBdg,UCmAf6BdYS-5QmXxBuJZgNpQ,UC6rDrJjome8e_iBQI1MLeZg,UCJ0lYZCucWTPc_IfE2vZNTg,UCVy5saLw3psF5laPWhahGHA,UCXskq-my9ltmT6SpdL7b_cw,UCpctmQs9AEwiIZgTcWSV0mg,UCv4ZlVO5-z-uVIm1Y6ol-DA,UCPtQnd-8OBSzvqnQVKaA_8g,UC_uQYR3lHS36jkBRqdvQIFw,UCoJuf64ajKTOZ6mX30zulKg,UCM-GJfgjXFajHll_uGeZPBQ,UC2ojGYd_fg8oU71beXUMW9g,UCT_dVMJ2eSGKugeXnMZcbfQ,UC6PHRps6wOfBJKoDxEI37Ew,UC2Ra3RK4FW38skAoYEtXJbQ,UC2u7_TuItL4on_9SuwJhO_A,UCt-gKqNg_k2bb-bSe7y3z4g,UC2UotqDGeOMUl-gQG3t9sKw,UCdbVBcrKBtu8oUcp4JuLpvw,UCKHpDyswx5VskURci4FPqUA,UCiNHdTU2jYRbUf1cbMCxdaQ,UC3osMa_MdseDVrXlbZFSZDw,UCbnwaC-Tbi1duuDbjfV-Thg,UCBOrTOryVc2JKsNOu7_wO6g,UCM8UoJ4z4NMvp5pwYQjx8uQ,UCnU2sysDk58MuMQHxqgDd7w,UCuldUFBFddgeVN6HJ-yIBjA,UCsEgNI5S2Vdy3Q7LizK2OSA,UClN9w3sTTs6lpntoeHyYvSA,UCgZlOI3AqanZW0tjCSJCKfA,UCqS9WhAUJ-6PiC-8mZ0rDSQ,UCBH5Es0HeCBBlHvWG9c2ipA,UCpPgyVE8TKJr-MnpB44Au4w,UCJxgQl6TU8FGmMzG24xxYFg,UCpe9hHSEkTs5BD6Ufi0-XuA,UCrk1G4da0dsnLsPjsov5fTA,UCtF629dMzswzAupMUEO-bPw,UCsRcjJkUmU_Ny5D9pn5ZGDw,UC5Wm0eXXRAA6Pcjlq8-EaLw,UCOakkksW_nWRDkPl43VzAQA,UC4JhVBsy-Yfr3dQy7G1EYuQ,UCfS8vOYmleKZU8zNjzsZ6qg,UCPWsJzhhZSPlfQ7DOjSA4Fg,UCPKKa8RgdfoMRBkyt8BhIqA,UCa3bfoq50eqErBDgq0p2cQA,UCyH05wKVW-96Lz2mqhGnzVw,UCiXjl5HwqmuCjr5ZmW00csQ,UCA9tlIHeg-k8z3PUpozkUmA,UC_Bc8M2p5fpYqlfWvbVmw2g,UCnD86huZnRWKDMZISbQx6kg,UCtRn5U4Uz2vbREF0qD0TLuA
I didn't get this in previous similar runs. What has changed?
API explorer
Nothing has changed, as far as I know. Fact is that -- with the exception of CommentThreads.list, Comments.list and Members.list endpoints -- all YouTube Data API endpoints that are providing result sets would not return result sets of more than 50 items.
Therefore, when using the Channels.list endpoint's request parameter id, you'll have to limit yourself to pass to it a comma-separated list of channel IDs of at most 50 elements.

Which groups allow selecting the properties allowExternalSenders or autoSubscribeNewMembers?

When I select the properties allowExternalSenders or autoSubscribeNewMembers for a group synced from an on-premise Active Directory, I get the following error via Graph API SDK:
403 Forbidden
Graph service exception Error code: AppOnlyAccessNotEnabledForTarget
Error message: App Only access is not allowed for target resource: 'a1d0c98e-fb7e-40c4-a7b5-ccf6d96cba57#34f0717f-f1a0-4894-b310-d379993504b9'.
The Graph Explorer displays the following 404 error, even though it is not a mailbox:
{
"error": {
"code": "MailboxNotEnabledForRESTAPI",
"message": "REST API is not yet supported for this mailbox.",
"innerError": {
"request-id": "5beae8eb-4a59-404f-bd42-0c6aa2a25abd",
"date": "2020-03-31T13:02:11"
}
}
}
An example request looks like this:
https://graph.microsoft.com/v1.0/groups/{id}?$select=id,deletedDateTime,assignedLicenses,description,displayName,groupTypes,licenseProcessingState,mail,mailEnabled,mailNickname,onPremisesLastSyncDateTime,onPremisesSecurityIdentifier,onPremisesSyncEnabled,onPremisesDomainName,onPremisesSamAccountName,preferredDataLocation,securityEnabled,securityIdentifier,visibility,resourceProvisioningOptions,allowExternalSenders,autoSubscribeNewMembers
Which property should I use to decide if I should try to select these properties or not? I want to avoid missing the properties for groups which actually do expose these properties, so I do not simply want to guess.
Slightly different take on this answer, Microsoft even thought only providing one API for groups, there are effectively two different objects returned, SecurityEnabled = True or False. If Security = True then you can not ask for the follow attributes
(allowExternalSenders,autoSubscribeNewMembers,hideFromAddressLists,hideFromOutlookClients)
Is this ok, NO its not ok, Microsoft needs to return null instead of providing THE WRONG ERROR MESSAGE and sending people like us into multi hour head scratchers.
In my code, I now check if securityEnabled is true or false and have a different set of attributes depending.
The mailbox is on a dedicated (on premise) Microsoft Exchange Server or is not a valid (configured) Office 365 mailbox. Contact your Exchange or Office admin to apply any of these recommended solutions.
To filter Office 365 groups you can do this:
https://graph.microsoft.com/v1.0/groups?$filter=groupTypes/any(c:c eq 'Unified')

Is it possible to filter email using EntryID (PR_ENTRYID) with Outlook REST API?

We are currently using EWS Managed APIs in our application and looking to migrate to use Outlook REST API approach. I am new to Outlook REST API world and looking for some inputs.
I am trying to fetch email from exchange using PR_ENTRYID with REST API and retrieve its properties, however always facing error like below:
Response status code does not indicate success: 400 (Bad Request).
Endpoint used :
https://outlook.office365.com/api/v2.0/me/messages?
Code:
Above endpoint is appended with below filter:
"$filter=SingleValueExtendedProperties/any(ep: ep/PropertyId eq 'Binary 0x0fff' and cast (ep/Value, Edm.Binary) eq '" + entryId + "')";
where entryId is
"00000000224A6557586868FH8N6765SZ6F78768686C9786R7658E8686860886D8768676C8B6CV75V7C57S6F5S8FSF7S9F7D86GD7G57D6G86D84000000"
also tried entryId of below form with no luck:
"AAAAACJKsh5bmbBdknCdkkjAAdjhV76ssn876fBDJg76jdkBfnnnkbslnKns76229873qHGHGnPPSHSFH+gdgf8BmF8aJdgaAAA=="
Please note that I am able to expand properties as mentioned here, however unable to filter/fetch email with that property. I have followed official documentation at official documentation
Any help is highly appreciated.
Thanks.

Resources