Outlook API v2.0 getEvents concurrency litmit - microsoft-graph-api

I am using outlook api v2.0 rest api to perform crud operations against calendars and events and have started hitting a rate limit issue.
This one for example is hitting the calendarview endpoint:
GET https://outlook.office.com/api/v2.0/me/calendars/{CALENDAR_ID}/calendarview
RESPONSE HEADERS
Rate-Limit-Limit=10000
Rate-Limit-Remaining=9982
Rate-Limit-Reset=2019-10-23T15:27:11.409Z
Retry-After=1
RateLimit-Exceeded=MailboxConcurrency
RateLimit-Scope=Mailbox
Transfer-Encoding=chunked
X-Proxy-BackendServerStatus=429
X-Powered-By=ASP.NET
X-RUM-Validated=1
RESPONSE BODY
{
"error": {
"code": "ApplicationThrottled",
"message": "Application is over its MailboxConcurrency limit."
}
}
At first I thought it was the 10.000 requests per 10 minutes period but it seems I am hitting a different one.

The error is showing that you've hit the mailboxconcurency limit. There is a limit of 4 concurrent requests as per the documentation.
Is there any reason you are using this API rather than Microsoft Graph also?
https://learn.microsoft.com/en-us/graph/throttling#outlook-service-limits

Related

Send message to self-Chat in Microsoft Teams using Graph API

I'm trying to send a message to my self-Chat in Microsoft Teams through a Graph API call but can't find the ID of this specific chat. For the record, this type of chat was introduced to Teams in June, 2022.
By reading the Graph API documentation, it's possible to list all chats available for a specific user using the following API call (in this case, myself):
[GET] https://graph.microsoft.com/beta/me/chats/
Yet, I can't seem to find my self-chat in there. The chat itself is already created since I wrote messages in it but it doesn't appear in the call response.
I've tried to filter the results by most recent results, by filtering on my own name or by filtering by ChatType, but it was still missing.
Is anyone aware of a way to get the ID of a user self-chat in Microsoft Teams?
Thanks!
Self chat is a special kind, You can use this endpoint to communicate with it:
https://graph.microsoft.com/v1.0/me/chats/48:notes/messages
Hope that helps :)
Answering harrywyn's question regarding the pop up notification, you can set it as unread the same as any chat like this:
EndPoint = f'https://graph.microsoft.com/v1.0/chats/48:notes/markChatUnreadForUser'
update_chat = {
"user": {
"id" : uid,
"tenantId": TENANT_ID
}
}
resp = requests.post(EndPoint, headers=headers, verify=False, json=update_chat)

How to get membership badges for YouTube live chat messages?

I've been poking around at the YouTube live chat API to render out a custom chat feed, and was wondering how I can show membership/sponsorship badges next to users like the YouTube site itself does?
Looking at a response from the API, I can see that YouTube does tell me the user is a member/sponsor, but it doesn't include at what level/duration nor what badge image should be shown:
{
"kind": "youtube#liveChatMessage",
"etag": "MHpDf4piJnYR2X3lP-7mwBavfWM",
"id": "LCC.CjgKDQoLd1VwYUIzYTdkVW8qJwoYVUNEWExPVjNTMEdUd21EOFY4R1A2dzlREgt3VXBhQjNhN2RVbxI7ChpDSVRodDQzS292VUNGZVV0clFZZHNJRUwzZxIdQ1B1VHJiYV9vdlVDRllhRGdnb2RaUE1LanctMjY",
"snippet": {
"type": "textMessageEvent",
"liveChatId": "Cg0KC3dVcGFCM2E3ZFVvKicKGFVDRFhMT1YzUzBHVHdtRDhWOEdQNnc5URILd1VwYUIzYTdkVW8",
"authorChannelId": "UCYC1zf9Dznp-xpe9rwEopLQ",
"publishedAt": "2022-01-08T16:31:12.317Z",
"hasDisplayContent": true,
"displayMessage": "Instead of waiting 30 seconds you had to spam facecam now you get a 5 minute timeout",
"textMessageDetails": {
"messageText": "Instead of waiting 30 seconds you had to spam facecam now you get a 5 minute timeout"
}
},
"authorDetails": {
"channelId": "UCYC1zf9Dznp-xpe9rwEopLQ",
"channelUrl": "http://www.youtube.com/channel/UCYC1zf9Dznp-xpe9rwEopLQ",
"displayName": "Cody Kerley",
"profileImageUrl": "https://yt3.ggpht.com/ytc/AKedOLQFiwv-x6ukfTOh7pD7WlCe7Ss1AB5wH7QAF53uiQ=s88-c-k-c0x00ffffff-no-rj",
"isVerified": false,
"isChatOwner": false,
"isChatSponsor": true,
"isChatModerator": true
}
}
But if I look at how this message was shown in the YouTube chat itself, the user has the correct membership badge for their level/duration, specific to this channel, and the tooltip also shows you the level/duration of the membership/sponsorship:
How can I get this information from the API for each chat message so that I can render the badge correctly myself?
Cheers.
As you said there doesn't seem to be any official YouTube Data API v3 endpoint providing membership badges for YouTube live chat messages.
However I reverse-engineered YouTube live chat messages and here is the solution:
Get a continuation token starting with 0ofMyAO (there seems to be 2 that both work) by executing (don't forget to change VIDEO_ID with your YouTube live video id):
curl -s 'https://www.youtube.com/live_chat?v=VIDEO_ID' -H 'User-Agent: Firefox/99'
Use this continuation token to fetch all pieces of information about current YouTube live chat messages by executing (don't forget to change CONTINUATION_TOKEN with the continuation token you grab at step 1., note: don't care about the key it's not a YouTube Data API v3 key):
curl -s 'https://www.youtube.com/youtubei/v1/live_chat/get_live_chat?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8' -H 'Content-Type: application/json' --data-raw '{"context":{"client":{"clientName":"WEB","clientVersion":"2.9999099"}},"continuation":"CONTINUATION_TOKEN"}'
Likewise you'll get all pieces of information about current YouTube live chat messages since the moment you grab the continuation token at step 1. however continuation token seems to expire every 5 minutes so grab a new one from the response of step 2. or by doing step 1. once again.
Note 0: during the 5 minutes window, you can execute step 2. as many time as you want to get messages in real time
Note 1: I recommend you to change the continuation token every 4 minutes in order not to miss any message
I let you understand the JSON response that contain the pieces of information you are looking for
Note: at step 1. you retrieve recent message sent before your request but it's in HTML format and not JSON this time

Microsoft teams messaging extension inconsistently sending a valid conversation ID to use in a graph call

I am developing a MSTeams application, and inside I use a messaging extension. Upon opening the extension, a request is fired over to my message handler, which I use an azure function to handle. Alongside the request is a payload, with details about the context (in this case the conversation or chat) of where the messaging extension was opened from.
Now, I've built up a graph URL with the conversation ID from the payload:
const id = context.req.body.conversation.id
const graphEndpoint = encodeURIComponent(`https://graph.microsoft.com/beta/me/chats/${id}/members`)
I authenticate a user by calling microsoftTeams.authentication.authenticate({...}) before I make the call, and use the token in the request.
Sometimes, this call will succeed, and return the information I want. However, the other times it will fail with a 400, telling me I had a bad request, despite it being a GET request with no body.
I notice in bad requests, that the conversation ID doesn't trail with #thread.v2 or #unq.gbl.spaces etc. I have no clue why this is so inconsistent, or if it's my fault. Any help would be appreciated.
EDIT: I have also seen that the issue only occurs when the id starts with a:, and succeeds when it starts with 19:. However, the context in which I open the messaging extension is the same each time: In a 1:1 / User:User chat.
I have previously implemented installing the bot in the conversation to get this information, but this method is very undesirable. Perhaps a side point - it seems that the conversations where I have previously installed the bot seem to return the 19: id, and everything else a:.
Here's an example of the 400 response:
{
"error": {
"code": "BadRequest",
"message": "Bad Request",
"innerError": {
"date": "2021-01-25T09:43:26",
"request-id": "3bb55aa2-e694-4c80-952c-88842f482dc1",
"client-request-id": "3bb55aa2-e694-4c80-952c-88842f482dc1"
}
}
}
The conversation id you received in the turn-context is not the chat-id. The conversation id is different from conversation id. Conversation id the id between bot and the user and chat id the id of the chat. Both are different. You cannot use conversation id to call the graph API. Please use the chat id to call graph API. You can get the chat id using list chats API.

Microsoft graph - outlook mail api

I'm using mail rest api for fetching messages. Value of property 'receivedDateTime' in response is showing time +4 than it is being showed in outlook.office365.com. That is, in mail web client if the received time is showing 'Mon 12:01 pm', 'receivedDateTime' in rest api response is showing '16:01', 4 more, means '4:01 pm'.
I tried below with different time-zones but results are always same:
Prefer: outlook.timezone="'Some' Standard Time"
But it is not working.
I want to receive same received time as it is showing in mail web client.
Microsoft Graph gives times in Coordinated Universal Time (https://en.wikipedia.org/wiki/Coordinated_Universal_Time) - that's what the "Z" in the timestamp indicates.
To get the user's timezone, call GET /users/{id|userPrincipalName}/mailboxSettings/timeZone. You can use this to adjust the times from Graph.
As far as I know you cannot receive times from Graph in any time zone other than UTC.
https://learn.microsoft.com/en-us/graph/api/user-get-mailboxsettings
https://learn.microsoft.com/en-us/graph/api/resources/message?view=graph-rest-1.0#properties

How reliable is yahoo finance?

How reliable is yahoo finance ?
For example the below request :
http://developer.yahoo.com/yql/console/?q=show%20tables&env=store://datatables.org/alltableswithkeys#h=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20%28%22YHOO%22%2C%22AAPL%22%2C%22GOOG%22%2C%22MSFT%22%29
intermittently returns the response : "The current table 'yahoo.finance.quotes' has been blocked. It exceeded the allotted quotas of either time or instructions"
Here is the complete response :
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="0" yahoo:created="2013-04-08T11:16:18Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-start-time="24" execution-stop-time="25"
execution-time="1" proxy="DEFAULT"><![CDATA[http://www.datatables.org/yahoo/finance/yahoo.finance.quotes.xml]]></url>
<cache execution-start-time="27" execution-stop-time="27"
execution-time="0" method="GET" type="MEMCACHED"><![CDATA[13c4f8eac77ad886bade5a711c8c1ef5]]></cache>
<javascript name="yahoo.finance.quotes" verb="select"><![CDATA[The current table 'yahoo.finance.quotes' has been blocked. It exceeded the allotted quotas of either time or instructions]]></javascript>
<user-time>28</user-time>
<service-time>1</service-time>
<build-version>35405</build-version>
</diagnostics>
<results/>
</query>
To get a reliable service do I need to sign up and pay ?
To get a reliable service do I need to sign up and pay ?
Here are the limits:
Public OAuth with API Key
Hourly Cap 2,000 20,000
Daily Cap None 100,000
To better understand the rate limits in the above table, let's use the following example. Suppose you create an application that generates around 3,000 requests from each user per hour. You notice though that users are capped at a maximum of 2,000 calls using the public endpoint, so you register an API Key with Yahoo! to use the authenticated/authorized endpoint. Now your users can make 20,000 requests per hour and up to a total of 100,000 requests per day.
oAuth is free.
References
YQL Overview - Yahoo Developer Network
Public API Down Detector

Resources