MS Graph API - Setting Out of Office replies - microsoft-graph-api

Trying to develop a Microsoft Graph based application. Trying to set OOF (Out of Office) messages using Delegated permission. I made sure that i have MailboxSettings.ReadWrite permission set. I tried calling PATCH, but it doesnt give any errors and also it's not updating the OOF update request in mailbox settings as well. Any pointers/sample would be of help.

I tried the below payload with MS Graph explorer & POSTMAN - it works for me!!
PATCH https://graph.microsoft.com/v1.0/me/mailboxSettings
Content-Type: application/json
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings",
"automaticRepliesSetting": {
"status": "Scheduled",
"scheduledStartDateTime": {
"dateTime": "2020-03-20T18:00:00.0000000",
"timeZone": "UTC"
},
"scheduledEndDateTime": {
"dateTime": "2020-03-28T18:00:00.0000000",
"timeZone": "UTC"
}
}
}
You can refer the documentation as well.

Related

How to allow Microsoft Team attendees to bypass lobby programatically (Microsoft Graph)

I've created an event on a calendar using Calendar API which in turn in the response, it will give me the link to a Microsoft Team meeting link. This is an example data that I've send when creating the event. Also, I'm calling this API as an App not as a user, so basically all 3 attendees are not part of the AD users.
{
"attendees": [
{
"type": "required",
"emailAddress": {
"address": "attendee1#domain.com",
"name": "Attendee 1"
}
},
{
"type": "required",
"emailAddress": {
"address": "attendee2#domain.com",
"name": "Attendee 2"
}
},
{
"type": "required",
"emailAddress": {
"address": "attendee3#domain.com",
"name": "Attendee 3"
}
}
],
"end": {
"dateTime": "2020-11-13T17:32:39.636Z",
"timeZone": "UTC"
},
"start": {
"dateTime": "2020-11-11T16:32:39.636Z",
"timeZone": "UTC"
},
"subject": "My online meeting",
"isOnlineMeeting": true,
"body": {
"content": "Does this time work for you?",
"contentType": "HTML"
},
"onlineMeetingProvider": "teamsForBusiness",
"allowNewTimeProposals": false
}
In the response, I receive something like this:
...
"onlineMeeting": {
"joinUrl": "https://teams.microsoft.com/l/meetup-join/19%3ameeting_NzRmMDIwMWEtNGYyZS00MmNkLTk3NTAtOGxxxxkOGQ4ZDUx%40thread.v2/0?context=%7b%22Tid%22%3a%22b82fec80-bee7-401e-xxxx-8a312e0a62d1%22%2c%22Oid%22%3a%22112d58ba-xxxx-47ce-a1a8-3d0abebead18%22%7d"
}
...
My problem right now is none of the attendees can start the meeting. I wonder if there's a way programatically either when I'm creating the event or updating the online meeting, to enable the attendees to bypass the lobby and start the meeting.
According to your parameter, I think you use Calendar event api to create an online meeting.
I also tried this and found that the attendees needs permission to enter the meeting room while the creater can enter directly. I googled and found no graph api could modify this configuration. The only way to make every attendee join the meeting without permission is changing the meeting option as 'everyone can bypass the lobby'
By the way, admin role account can login the Microsoft teams admin center and automatically allow people in your organization bypass the lobby. This document tells the detail.
Actually, I used Fiddler to catch the changing option request and got a url like https://teams.microsoft.com/api/mt/amer/beta/meetings/v1/options/.... and an access token. I can use them to change the option successfully by sending a http post request. All seems the answer will appear but unfortunately after analizing the access token I found the api needs a permission https://api.spaces.skype.com which is not supported by Azure ad.

Creating events in calendar with Graph API returns "ResourceNotFound"

I'm trying to create events in my personal calendar (Office 365 account) with Graph API. I create a instance on my tenant on Azure with the following delegated permissions: Calendars.Read, Calendars.ReadWrite, email, offline_access, openid, profile and User.Read.
The oAuth2 sign-in occours as expected and I receive both the bearer_token and the refresh_token, using the /.default scope. But when I try to make the request:
POST /v1.0/me/calendar/events HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer eyJ0eXAi...
Content-Type: application/json
{
"subject": "Example",
"body": {
"contentType": "text",
"content": "Example description"
},
"start": {
"dateTime": "2020-09-01T12:00:00.000Z",
"timeZone": "America/Sao_Paulo"
},
"end": {
"dateTime": "2020-09-01T13:00:00.000Z",
"timeZone": "America/Sao_Paulo"
},
"location": {
"displayName": "Example location",
"locationUri": "https://example/uri"
}
}
I get this response:
{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"date": "2020-08-31T22:18:15",
"request-id": "f03d0bdf-1a9c-41f4-a236-1c5a41a5d286"
}
}
}
I already had discarted that is a mailbox problem, because with Graph Explorer I can make the request and change my calendar, so I'm willing to think that is a permission problem.
I found out, the problem was not with the Graph request, but with the authentication request.
When you log into Graph API with a coorporative account, the requests to get the bearer_token are:
https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize
https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token.
But when you use a personal account, the endpoints are:
https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize
https://login.microsoftonline.com/consumers/oauth2/v2.0/token.
Using the tenantId will authenticate, but the user data will not be found in the tenant, giving the error I got.

Auto create hang out links

I am working on an application. We have successfully implemented "Google.Apis.Calendar.v3". Events are created and showing in calendar. But while creating the event I want to add functionality to auto create hangout link which i can use and send to customers. I want to ask is it possible to do it through "Google.Apis.Calendar.v3.Data". If yes, how I can implement. I will really appreciate your help.
Regards,
When making the request to create the event using insert or modifying an event using patch, you simply need to:
Set the conferenceDataVersion parameter equal one (1).
In the body add the option to "createRequest" and a "requestId" in the body as part of the "conferenceData" option like:
{
"end": {
"dateTime": "2020-07-29T09:00:00-07:00",
"timeZone": "America/Los_Angeles"
},
"start": {
"dateTime": "2020-07-28T09:00:00-07:00",
"timeZone": "America/Los_Angeles"
},
"conferenceData": {
"createRequest": {
"requestId": "<for-you-to-decide>"
}
}
}
Note:
Keep in mind the conferences are created asynchronously, but you can always check the status of your request to let your users know what’s happening. The immediate response to this call might not yet contain the fully-populated conferenceData which is indicated by status pending.
You can read about it here or in the Documentation

Microsoft Graph API: Create events for users that are not me

I'm currently developing a small managing app that should create events within a specific Microsoft calendar but I'm only able to do this for me as the authorized user.
Is there an option to create events for everyone in this calendar with only knowing the userPrincipalName?
{
"subject": "test",
"body": {
"contentType": "HTML",
"content": "Sample Text"
},
"start": {
"dateTime": "2019-04-04T12:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2019-04-04T14:00:00",
"timeZone": "Pacific Standard Time"
},
"location":{
"displayName":"Testlocation"
}
}
https://graph.microsoft.com/v1.0/users/myPricipalName/calendar/events works but only for me.
The whole documentation is a bit overwhelming
The answer is yes, but you're right about the documentation...
You'll have to take the following steps:
Create an application documentation
Add the following permission Read and write calendars in all mailboxes for the Microsoft Graph API.
Grant the permission for your tenant (the easiest way is through https://portal.azure.com -> Azure AD -> App Registrations -> Your App -> Settings -> Required permissions -> Button Grant Access.
Request a token with the client id and secret, this is called the Client credentials flow documentation
(optional) Inspect the token on https://jwt.ms to see if the token is correct.
Create an event documentation
Celebrate your accomplishment with some refreshments.
The best approach would be to get an application token, an application which has been granted permission to write users’ calendars.

"Exception has been thrown by target of an invocation" for /findMeetingTimes request

I am developing a multi-tenant application with the Microsoft Graph API that makes use of the /findMeetingTimes endpoint. After many months of successful requests, on January 15th I started to see some errors coming through for a specific kind of request for some users.
The failing request is a POST to /findMeetingTimes for a single attendee who is the user on who's behalf I'm making the request. The same requests for more than a single attendee are still completing just fine, even if the user who authorized the request is included.
Nothing has changed in my request so this seems like it's either a change on the API side or a change in the user's configuration that's broken their ability to make requests of this type. Any insight on this error in this context would be helpful!
POST https://graph.microsoft.com/v1.0/me/findMeetingTimes
Request body:
{
"attendees": [
{
"emailAddress": {
"address": "[email of user who authorized the request]"
},
"type": "Required"
}
],
"meetingDuration": "PT30M",
"minimumAttendeePercentage": 100,
"maxCandidates": 400,
"timeConstraint": {
"timeslots": [
{
"start": {
"dateTime": [DateTime],
"timeZone": "UTC"
},
"end": {
"dateTime": [DateTime],
"timeZone": "UTC"
}
}
],
"activityDomain": "Unrestricted"
}
}
Returns (one specific example):
500: "Exception has been thrown by the target of an
invocation.", "innerError":{"request-id":"a039234e-f64e-489a-96cf
ff4f686a4389","date":"2018-01-18T01:51:49"}

Resources