Bad Gateway 502: Add member to Teams using Graph beta Api - microsoft-graph-api

The add member to Teams graph beta API works with some users while it gives me a 502 error with others.
Add member - https://learn.microsoft.com/en-us/graph/api/team-post-members?view=graph-rest-beta&tabs=http
In either scenario, the call is exactly the same and the only thing that changes is the user ID
POST https://graph.microsoft.com/beta/teams/{id}/members
Content-type: application/json
Content-length: 26
{
"#odata.type": "#microsoft.graph.aadUserConversationMember",
"roles": ["owner"],
"user#odata.bind": "https://graph.microsoft.com/beta/users/{userID}"
}
Why would this be happening? Is there any way to solve this?

Related

Create Team, 400 Bad Request, Required functionality is not supported

I'm trying to create a Microsoft Teams team in Migration mode via the Graph API. However I get a 400 response that I can't figure out. The query is shared in the link below.
Shared Query
For those that don't want to view it that way, here is my request:
POST https://graph.microsoft.com/beta/teams
Authorization: Bearer ...
Content-Type: application/json
{
"#microsoft.graph.teamCreationMode": "migration",
"template#odata.bind": "https://graph.microsoft.com/beta/teamsTemplates(\u0027standard\u0027)",
"displayName": "SlackMigrationTest",
"description": "testing slack migrations",
"createdDateTime": "2021-01-14T00:00:00.000Z"
}
I created this based on the microsoft doc here.
The reponse I get is:
The remote server returned an error: (400) Bad Request.
{
"error": {
"code": "BadRequest",
"message": "Required functionality is not supported.",
"innerError": {
"date": "2021-01-20T15:51:21",
"request-id": "dc4189cf-db4a-4a60-a271-f63b5d759a05",
"client-request-id": "dc4189cf-db4a-4a60-a271-f63b5d759a05"
}
}
}
I'm sure its something obvious that I'm missing but any help would be greatly appreciated.
Here you are using the User Context token and trying to make the call. This API call only works in Application context as shown in the below screenshot.
So use Client Credential flow and set Application permissions and then make a call.
As you can see below, it worked for me with App token.
You cannot test it in graph explorer because the Graph Explorer gets user token.

Xero API fetch list of organization (all organization)

I have done OAuth2.0 using PKCE flow in .NET Framework (C# Winforms).
Now I have tokens_response in my hand.
But I'm wondering is it possible to fetch all of the organisation (not only one)?
You can check the organisations (tenants) that you can access with a given token using the /connections endpoint, like this:
GET https://api.xero.com/connections
Authorization: "Bearer " + access_token
Content-Type: application/json
Response:
[
{
"id": "e1eede29-f875-4a5d-8470-17f6a29a88b1",
"authEventId": "d99ecdfe-391d-43d2-b834-17636ba90e8d",
"tenantId": "70784a63-d24b-46a9-a4db-0e70a274b056",
"tenantType": "ORGANISATION",
"tenantName": "Maple Florist",
"createdDateUtc": "2019-07-09T23:40:30.1833130",
"updatedDateUtc": "2020-05-15T01:35:13.8491980"
},
{
"id": "32587c85-a9b3-4306-ac30-b416e8f2c841",
"authEventId": "d0ddcf81-f942-4f4d-b3c7-f98045204db4",
"tenantId": "e0da6937-de07-4a14-adee-37abfac298ce",
"tenantType": "ORGANISATION",
"tenantName": "Adam Demo Company (NZ)",
"createdDateUtc": "2020-03-23T02:24:22.2328510",
"updatedDateUtc": "2020-05-13T09:43:40.7689720"
}
]
If you need more information than the organisations' id and name, you'll need to call the /organisation endpoint individually for each.
The connections endpoint is described more in section 5 on this page of the docs: https://developer.xero.com/documentation/oauth2/auth-flow

Microsoft Graph API Online Meeting Delete not working

I successfully created an online meeting with the following API.
POST https://graph.microsoft.com/beta/communications/onlineMeetings
Content-Type: application/json
{
"startDateTime":"2019-09-09T14:33:30.8546353-07:00",
"endDateTime":"2019-09-09T15:03:30.8566356-07:00",
"subject":"Application Token Meeting",
"participants": {
"organizer": {
"identity": {
"user": {
"id": "550fae72-d251-43ec-868c-373732c2704f"
}
}
}
}
}
But when I am trying to delete the meeting its not working. I tried with the following APIs:
DELETE https://graph.microsoft.com/beta/me/onlineMeetings/{meeting id}
and
DELETE https://graph.microsoft.com/beta/{user id}/onlineMeetings/{meeting id}
Please help.
The api documented here works for me, eg:
DELETE https://graph.microsoft.com/beta/me/onlineMeetings/550fae72-d251-43ec-868c-373732c2704f_19:meeting_M2IzYzczNTItYmY3OC00MDlmLWJjMzUtYmFiMjNlOTY4MGEz#thread.skype
I get an http 204 in response.
Note that even after deleting the meeting using the above api, I am still able to join the meeting from the teams client, this may be a different bug perhaps. However, trying to delete the same meeting id again gives a 404 not found, which is expected.

Unable to update to mail enabled security group by Microsoft Graph API

I'm getting below error while updating a security group (created through API) to mail enabled security group via Microsoft Graph API.
{
"error": {
"code": "Request_BadRequest",
"message": "The service does not currently support writes of mail-enabled groups. Please ensure that the mail-enablement property is unset and the security-enablement property is set.",
"innerError": {
"request-id": "34bc9a4d-9e52-4c2e-b847-99f8dbf43518",
"date": "2018-04-09T13:05:10"
},
"details": [
{
"target": "mailEnabled",
"code": "InvalidValue"
}
]
}
}
As per https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/group_update#request-body documentation, I believe it is possible to have a security group with mail enabled feature.
This is raw request(Captured through Fiddler).
PATCH https://graph.microsoft.com/v1.0/groups<<groupId>> HTTP/1.1
Accept: application/json
Authorization: Bearer <<Authorization Token>>
Content-Type: application/json; charset=utf-8
Host: graph.microsoft.com
Content-Length: 96
Expect: 100-continue
Connection: Keep-Alive
{"mailEnabled":true,"mailNickname":"<<mailNickName>>"}
Please suggest if the request need to formed in a different format?
I'm afraid Mail-enabled Security Groups are not fully supported by Microsoft Graph. From the documentation:
Mail-enabled security groups can't be created through the API, but other group operations work. Mail-enabled security groups are read only.
Mail-enabled security groups can be managed via Exchange. You can find more details on this in Manage mail-enabled security groups in Exchange 2016.

Profile details in outlook rest api

Starting from here: https://dev.outlook.com/restapi/tutorial/php
Scopes:
private static $scopes = array("openid"
,"profile"
,"offline_access"
,"https://outlook.office.com/calendars.read"
,"https://outlook.office.com/contacts.read"
);
When I authenticate I get in id_token only some basic info about the profile.
With:
https://outlook.office.com/api/v2.0/me/contacts
I get some very nice details about contacts, like phone numbers that I'm specially interested in my case.
Is possible to get the same level of details for the current user profile as you get for one of its contacts when is accessed through the api?
How about using the Microsoft Graph API:
GET https://graph.microsoft.com/v1.0/me
The response should like as following:
HTTP/1.1 200 OK
Content-type: application/json
Content-length: 491
{
"businessPhones": [
"businessPhones-value"
],
"displayName": "displayName-value",
"givenName": "givenName-value",
"jobTitle": "jobTitle-value",
"mail": "mail-value",
"mobilePhone": "mobilePhone-value",
"officeLocation": "officeLocation-value",
"preferredLanguage": "preferredLanguage-value",
"surname": "surname-value",
"userPrincipalName": "userPrincipalName-value",
"id": "id-value"
}
Graph API - Get user

Resources