Outlook contact folders (Categories) subscription API issue - outlook

API Availability? - Is there any APIs to subscribe create contact category resource?
We are currently using the contact folder subscription for that we are facing the below issue.
Issue description - For the create/update contact, we do not receive any notification from Microsoft for graph and graph beta API.
Details used:
Request body: {"notificationUrl":"","expirationDateTime":"2023-27-06T04:15:43Z","resource":"/me/contactFolders/<%contactFolderid%>/contacts","changeType":"created,updated,deleted","clientState":""}
API used - https://graph.microsoft.com/v1.0/subscriptions (Microsoft documentation)

According to the doc maximum length of subscription for contacts resource is 4230 minutes (under 3 days).
Your expirationDateTime=2023-27-06T04:15:43Z is strange. Based on expected format yyyy-MM-ddThh:mm:ssZ you set the month to 27.
Based on this probably only resources /me/contacts or /users/{user_id}/contacts are supported, not /me/contactFolders/<%contactFolderid%>/contacts.
Try to create a subscription with expirationDateTime that doesn't exceed 3 days
{
"notificationUrl":"<your_notification_url>",
"expirationDateTime":"2023-01-28T04:15:43Z",
"resource":"/me/contactFolders/<%contactFolderid%>/contacts",
"changeType":"created,updated,deleted",
"clientState":""
}
If possible in your case you can use delta to periodically get a set of contacts that have been added, deleted, or updated in a specified folder.
GET /me/contactFolders/{id}/contacts/delta
GET /users/{id}/contactFolders/{id}/contacts/delta

Related

Outlook / Exchange API (Microsoft Graph?)

I am making a quick program that can check another users Outlook calendar and book an appointment. The booking part is fine, but I am looking at a way to return other users calendar information, without having to link a calendar to Outlook first.
I was thinking that there would be an API or a way to access this information either via 365 or the exchange server. There is this (https://learn.microsoft.com/en-us/previous-versions/office/office-365-api/?redirectedfrom=MSDN#Getevents) but it doesn't seem to do what I am after and is also deprecated with an end date within a year
I have read about Microsoft Graph but in reading it refers to 'users calendar', can this do calendars for a specific user that isn't me?
GET /me/calendar/calendarView?startDateTime={start_datetime}&endDateTime={end_datetime}
If so, does anyone know how?
Thank you
You can access user's calendar by calling the following endpoint
GET /users/{id | userPrincipalName}/calendarView?startDateTime={start_datetime}&endDateTime={end_datetime}
Resource:
List calendarView

Outlook Add-in REST API In Shared Inbox Fails: ErrorInvalidMailboxItemId - Item Id doesn't belong to the current mailbox

We have an Outlook (Office JS) Add-in with a manifest configured to support shared folders, i.e.
<SupportsSharedFolders>true</SupportsSharedFolders>
The add-in has been running flawlessly, for many months, on a number of machines that meet the minimum requirement set of 1.8 for shared folder support. Since 22-Apr-2020 it has returned the following error when selecting an email in a shared email inbox:
Status Code: 404
ErrorInvalidMailboxItemId - Item Id doesn't belong to the current mailbox
The REST API call that returns this error is:
https://outlook.office.com/api/v2.0/me/messages/<RestID>/
Where <RestID> is created from: Office.context.mailbox.convertToRestId(Office.context.mailbox.item.itemId, Office.MailboxEnums.RestVersion.v2_0)
Has an API change been documented anywhere?
Do we need to modify our code?
This is not a recent change. The REST URL should be constructed based on the SharedProperties descrbied here https://learn.microsoft.com/en-us/javascript/api/outlook/office.sharedproperties?view=outlook-js-1.8 Note that the SharedProperties API is only available for shared items.

outlook calendar events for rooms

I am making a web app which pulls the names and events of rooms from outlook calendar. I am able to get rooms list but how can I get the calendar schedule for each room. How would the get request look like then?
Here's the link of the tutorial that I used: Build Node.js Express apps with Microsoft Graph
Here's the link of the documentation of the room list: user: findRooms
The getSchedule method get the free/busy availability information for a collection of users, distributions lists, or resources (rooms or equipment) for a specified time period.
POST /users/{id|userPrincipalName}/calendar/getSchedule
If successful, this method returns a 200 OK response code and a collection of scheduleInformation objects for each object in the schedules parameter.
It looks like the API is still in Beta and not yet supported in production applications. So, I'd suggest double check whether it works now in production or not.

Microsoft Graph List Contacts API returns contacts beyond what are visible in the Outlook UI

Outlook UI
You can see that I've made three test contacts in the UI accessible here: https://outlook.live.com/people/
Microsoft Graph List Contacts API
When I call the List Contacts API (https://graph.microsoft.com/beta/me/contacts?$orderby=createdDateTime desc&$top=50), I get a list of contacts that is much more extensive than the list visible in the UI. These contacts appear to be anyone that has emailed me or anyone that I've emailed.
The problem
If I want to poll against the GET /me/contacts endpoint to get some data whenever I make a new contact, I'll end up getting notified every time someone new sends me an email or every time I send someone new an email (even if I didn't manually create the contact).
Is this intentional? If so, are there any filters I could add to specify that I don't want to get contacts that were not manually created by me? Looking over the JSON representation of a contact, I don't see anything I can filter on.
Possible Solution
My only thought is that I notice that the contacts made for me exist in a folder that is not returned in the contactFolders API endpoint. I could theoretically make a call to that endpoint and take the list of contacts returned and check if the parentFolderId exists in there. If it does, presumably that's because we created a contact and if not then it's made for us. That feels terribly hacky, though.
Thanks for the help!
This is an issue with the Microsoft Graph Beta APIs. Switching to the v1.0 of the Graph REST APIs resolved this.
It seems Outlook automatically adds every email address that had been in contact with the user as a hidden contact in a hidden folder.
The GET beta/me/contacts endpoint (unlike the v1.0 one) returns all contacts from all folders, so it also includes this hidden folder.
There are two ways to get the expected list of contacts:
Option 1 - get all contacts, and then filter:
GET /beta/me/contactFolders to obtain a list of "real" folders (this endpoint does not return that hidden folder)
GET /beta/me/contacts to get all contacts in the account
Filter the list of contacts by field parentFolderId - to keep only contacts in one of the folders returned at step 1
Option 2 - get contacts by folder:
GET /beta/me/contactFolders to obtain a list of "real" folders (this endpoint does not return that hidden folder)
for each folder returned call GET /beta/me/contactFolders/{folder-id}/contacts and aggregate the returned contact lists
Hope this helps.

Yammer API Find Pending Users

Is it possible to find a list of Yammer users in the 'pending' state using the API?
(we have a growing list of old invites that need to be purged regularly)
Tried a number of options:
The find all users endpoint, paging to 50 per page seems to only return 'active' users (scanned 100+ pages).
https://www.yammer.com/api/v1/users.json
The find by email endpoint returns all user states, although requires knowing the email.
The export users API endpoint produces a .zip file
Pending users were recently added as mentionable:
https://about.yammer.com/yammer-blog/mentioning-pending-users-designing-building-testing-features-yammer Should this recent change have also made pending users visible via the users.json endpoint ?
I know pending users can be identified in the manual user.csv extract by having no join date, no deletion and no suspended date, although how can they be identified via the API? users.json seems to not provide this functionality.
Has anyone been able to automate the deletion of pending users in Yammer via the API?
You can use the Data Export API. Extract the users.csv from the ZIP file using code and then filter for pending users. Pending users do not have a joined_at, suspended_at, or deleted_at date.
NOTE: If you are intended to "remove" a pending user, you must always check if that email address also has an active user associated. An email address can show up multiple times in users.csv. When you do remove a user always suspend the user because it can be undone.
Here's an endpoint you can run a GET on an return the JSON output of the pending user list:
https://www.yammer.com/<your Yammer network>/contacts/network
Example:
https://www.yammer.com/contoso.com/contacts/network
Note: this is an undocumented endpoint so the functionality could change at any time.

Resources