Microsoft Graph Calendar API - TargetIdShouldNotBeMeOrWhitespace error - microsoft-graph-api

We use Microsoft Graph API's to create a calendar in outlook
Following is the HTTP Request
POST https://graph.microsoft.com/v1.0/users/me/calendars
Content-type: application/json
{
"name": "My Calendar"
}
It was working for the last 2 years. Suddenly it is throwing an error as
{
"error": {
"code": "TargetIdShouldNotBeMeOrWhitespace",
"message": "Id is malformed.",
"innerError": {
"request-id": "78bce863-d6fb-4ea9-b0f8-e5097010cef6",
"date": "2019-03-23T11:54:34"
}
}
}
When we searched the documentation (https://learn.microsoft.com/en-us/graph/api/user-post-calendars?view=graph-rest-1.0).
We found the API URL has been changed
When was a critical update like this was rolled out which caused breakage in our flows?
Is there any official channel/group notifying these changes.
similar question for mail API's Microsoft Graph API - SendMail http 400 - API url from documentation not working

The correct URI is /me, not /users/me. Behind the scenes, /me is just an alias for /users/{id}. Asking for /users/me would be the equivalent of asking for /users/users/me.
It sounds like you were making use of an unintended behavior. It stopped working when that behavior was corrected.

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.

Teams listChannel Graph API resulting in "Unauthorized error - "Failed to execute Aad backend request GetUsersByObjectIdsRequest"

The teams list channel Graph API has started throw Unauthorized error as below. It use to work fine until yesterday. We are using "ServicePrincipal" for authentication and it has all necessary graph permission. In this case - Group.Read.All
Sample endpoint we are using is as below.
https://graph.microsoft.com/v1.0/teams/dccde580-0fc5-11eb-adc1-0242ac120002/channels.
Since this morning, it is failing continuously with the below error. More over, this is not a beta API.
As per our analysis, it is failing for those teams which has a private channel it. But as per documentation, private channels should be returned in the response as well. I dont understand what could be the issue.
Any idea / hints /help in this regard is really appreciated.
{
"error": {
"code": "Unauthorized",
"message": "Failed to execute Aad backend request GetUsersByObjectIdsRequest. Workload Unknown. Request Url: https://graph.windows.net/myorganization/getObjectsByObjectIds?api-version=1.61-internal, Request Method: POST, Response Status Code: Unauthorized, Response Headers: ocp-aad-diagnostics-server-name: 0yK5pQbb6mmQTig21hH07WmGI0k2nuTime8Zw4wMO7k=\r\nrequest-id: c33c655e-27f7-4f96-aabf-70e6d9d8770d\r\nclient-request-id: 5bd775a7-7dba-4ad7-bc9a-fbd91ae46fea\r\nStrict-Transport-Security: max-age=31536000; includeSubDomains\r\nDate: Fri, 16 Oct 2020 15:23:45 GMT\r\n, Reason Phrase: Unauthorized",
"innerError": {
"date": "2020-10-16T15:23:45",
"request-id": "3f3793b8-02d6-4653-a14f-3e455660e3d8",
"client-request-id": "3f3793b8-02d6-4653-a14f-3e455660e3d8"
}
}
}
We are facing the same issue, and the error exist in some of our test tenants and it will thrown by microsoft when we using the application permission to make the request.
The requests with the delegate permission token work without any issue.
Microsoft adds some Permissons.
https://learn.microsoft.com/de-de/graph/api/channel-list?view=graph-rest-beta&tabs=http
Do you have the application permissons?
Do you use the beta endpoint?
Look at this: https://learn.microsoft.com/de-de/microsoftteams/platform/graph-api/rsc/resource-specific-consent

Microsoft Graph API - SendMail http 400 - API url from documentation not working

My application sends email using Microsoft Graph. We followed the documentation, this was working as expected for almost a year:
https://graph.microsoft.com/v1.0/users/me/microsoft.graph.sendmail
Since 3/8/2019, the same code sendmail API in PROD started failing with the HTTP 400 - Bad Request:
{
"error": {
"code": "TargetIdShouldNotBeMeOrWhitespace",
"message": "Id is malformed.",
"innerError": {
"request-id": "0de5a4eb-dac4-4d98-a4b4-178e503a6657",
"date": "2019-03-19T17:16:20"
}
}
}
As a part of the investigation, we found that the SendMail documentation has a different URL used in the examples than the API help section. We were successful when calling this URL:
https://graph.microsoft.com/v1.0/me/sendmail
Questions:
Clearly looks like there was some update on the Graph API happened around 3/8/2019 that disabled working of the earlier URL
Documentation has 2 URL's that are misleading/confusing: one is the API help section and one in examples. As of now the API URL in the help section is no longer working. That should be fixed with the correct URL to be used.
Why was such breaking change like this introduced that caused a PROD outage for our application?
What is the official channel to get these changes?
The correct URI is https://graph.microsoft.com/v1.0/me/microsoft.graph.sendmail (not /me)
The correct API route is: https://graph.microsoft.com/v1.0/me/sendMail
You can find more practical samples here: https://developer.microsoft.com/en-us/graph/graph-explorer#

Can't access /outlook/masterCategories endpoint in Microsoft Graph's API

It seems any endpoints starting starting with /outlook return this error:
GET https://graph.microsoft.com/beta/me/outlook/masterCategories
{
"error": {
"code": "RequestBroker-ParseUri",
"message": "Resource not found for the segment 'Outlook'.",
"innerError": {
"request-id": "a75d1c9a-c6ae-4b69-83ca-fc0e467a4ad7",
"date": "2017-12-26T17:23:17"
}
}
}
I have authorized the scopes mail.read user.read mailboxsettings.readwrite so I should be able to access a user's inbox categories, but the beta API endpoints starting with "outlook" mentioned in this post:
https://blogs.msdn.microsoft.com/exchangedev/2017/10/09/new-outlook-apis-in-the-microsoft-graph-rooms-rules-categories-headers-and-time-zones/
are not accessible whatsoever, am I doing something wrong?
Keep in mind I tested this endpoint and it works perfectly: https://graph.microsoft.com/beta/me/mailFolders
but this one: https://graph.microsoft.com/beta/me/outlook/masterCategories returns the error above.
I'm afraid the /beta documentation is a bit ahead of the /beta code itself. Currently the beta/me/outlook/ endpoints (including /masterCategories) do not support MSA/Personal accounts.
I've been unable to definitively confirm if/when support is forthcoming (not all that surprising given the time of year), so I'm afraid I don't have an ETA on when this might roll out.

GraphApi API error codes

I am attempting to create a interface between our web application and the GraphApi.
I am currently struggling to handle error correctly as the documentation for graph API seems to be at best incomplete. Is there a reference to full list of errors one should expect.
An example of the issue is where I make a request after my access token has expired. The error code is not on the list (graph.microsoft.io docs/overview/errors page) and in a different format (capitalization). It also seems to vary drastically from the azure error codes such as "Request_BadRequest". This was found in an MSDN article titled "Error codes and error handling | Graph API concepts".
The document states "You may use the information returned here instead of, or in addition to the HTTP status code returned.". However, this is really hard if they are changing despite being out of beta.
example of an error response body:
{ "error": {
"code": "InvalidAuthenticationToken",
"message": "Access token has expired.",
"innerError": {
"request-id": "267438d2-4cc5-4621-9307-2af26d2f5b49",
"date": "2016-02-16T13:30:24"
}
}
}

Resources