OneNote API for sovereign network - microsoft-graph-api

I'm trying to test on the China sovereign network.
Using these 2 API endpoints for Authentication and Graph API.
https://login.chinacloudapi.cn, https://microsoftgraph.chinacloudapi.cn
Microsoft.Graph.GraphServiceClient graphClient = GraphProvider.GetGraphServiceClient(tenantName, clientId, clientSecret);
graphClient.BaseUrl = "https://microsoftgraph.chinacloudapi.cn/V1.0";
...
var notebooks = await graphClient.Users[userPrincipalName].Onenote.Notebooks.Request().GetAsync();
This does not seem to be working for the China sovereign network. (Works fine for ordinary US endpoint)
Here's the packet dump
Request
GET
/V1.0/users/??????/onenote/notebooks
HTTP/1.1
SdkVersion: Graph-dotnet-1.12.0
Authorization: Bearer
eyJ0eXAiOiJKV1QiLCJub25jZSI6IlFrQ1dPOTFCcWhuMWVub0d3MmRLT3B3aXozS1ZPNnB2TV93Tjl2Vk1va0kiLCJhbGciOiJSUzI1NiIsIng1dCI6InljS3RWOG1aX0pmM25CVmJmZzRmblp1TFFSYyIsImtpZCI6InljS3RWOG1aX0pmM25CVmJmZzRmblp1TFFSYyJ9.eyJhdWQiOiJodHRwczovL21pY3Jvc29mdGdyYXBoLmNoaW5hY2xvdWRhcGkuY24iLCJpc3MiOiJodHRwczovL3N0cy5jaGluYWNsb3VkYXBpLmNuLzljZGE1YzQ2LTk1NjItNGFhNy05NzQyLTE3MjBjZjRlMmQwZi8iLCJpYXQiOjE1Nzk3MTk1NjcsIm5iZiI6MTU3OTcxOTU2NywiZXhwIjoxNTc5NzIzNDY3LCJhaW8iOiJZMlZnWUpqeTdqN1hVOG05TExFOGZjNHJwdDVZQ2dBPSIsImFwcF9kaXNwbGF5bmFtZSI6IkNvbW12YXVsdF9UZXN0IiwiYXBwaWQiOiI2YjliNTE0Mi0xOWY4LTQ2MGUtYWNjOC02ZTU5M2MxNGI0NTYiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy5jaGluYWNsb3VkYXBpLmNuLzljZGE1YzQ2LTk1NjItNGFhNy05NzQyLTE3MjBjZjRlMmQwZi8iLCJvaWQiOiI1ZGQ0ZTM3Mi03NWVjLTRhYTEtODhkNy00ZDliOTAyZDI1ZjYiLCJyb2xlcyI6WyJTaXRlcy5SZWFkV3JpdGUuQWxsIiwiRGlyZWN0b3J5LlJlYWQuQWxsIiwiVXNlci5SZWFkLkFsbCJdLCJzdWIiOiI1ZGQ0ZTM3Mi03NWVjLTRhYTEtODhkNy00ZDliOTAyZDI1ZjYiLCJ0aWQiOiI5Y2RhNWM0Ni05NTYyLTRhYTctOTc0Mi0xNzIwY2Y0ZTJkMGYiLCJ1dGkiOiIwRS1Wdmp0WFBrLURVdUZXaFpBWEFBIiwidmVyIjoiMS4wIiwieG1zX3RjZHQiOjE1NzM0NjEzNzF9.y5QkGFjb2_EFB0oexXgdSZxbkHkKrkcc5GgpmrH0I2865LQ0vPkkK2efyJU19tEKNhkWXXADAsD76SalzSheu7hQ69sCj-HsXyRbG-Ue03KMmD2KsXRVFK-bVrjF1vJl9k5zKUeYP0rw5sjc7G33GmYh6L6iFm8y_PHg9W14JOfvCaMsvu0QXK9UTc7AWUy09L71ZVw6SGEokfayFfjqh8bkq7jI8CuvOV61tAUgmUJvIijSsl6HwoHVrMJ5D_RLLPdkOD01fN4YDkYCsleEDsgLnqXpzmtOPABzgVuyDfk-saAo4PLl-omN4OTx5-_bJjq5LM_SqTnELihSrYCkaw
Cache-Control: no-store, no-cache
Host: microsoftgraph.chinacloudapi.cn
Response
{ "error": {
"code": "Request_BadRequest",
"message": "Unexpected segment OpenPropertySegment. Expected property/$value.",
"innerError": {
"request-id": "a4cf5da0-715e-4dbd-ad1e-fd4b5e8f2134",
"date": "2020-01-22T19:04:31"
} } }
Am I missing something when calling the API?
Thanks.

Sorry Locke but OneNote is not supported on Microsoft Graph in China for now

Related

Getting 400 Bad Request with Error code 'noResolvedUsers' when granting permission to a valid email address using Microsoft Graph API

The below graph endpoint is used to grant access to the recipients on a drive item.
POST /drives/{drive-id}/items/{item-id}/invite
We are getting 400 Bad Request with Error code noResolvedUser, when a valid email address is added as recipient.
Request Method: POST
https://graph.microsoft.com/v1.0/drives/b\u00219b-VFEZXFE2F6XaM23GxN8X-1eQtnPNKnMeB6Rp23ucBGLuKk3pmT5OkkLL5Q1l7/items/01Q2A2TZG5GSOV2XYB7FEKPGK4VD6S7OI3/invite
Status Code: 400 Bad Request
client-request-id: e1646495-3606-4e49-88ad-2d977d284164
Cache-Control: no-cache
Content-Type: application/json
"error": {
"code": "noResolvedUsers",
"message": "One or more users could not be resolved.",
"innerError": {
"date": "2021-06-15T08:41:35",
"request-id": "607b3ce3-e29b-45a9-9942-7528e43fe8b4",
"client-request-id": "e1646495-3606-4e49-88ad-2d977d284164"
}
}
We could not find documentation for the error code 'noResolvedError'.
Many tenants are experiencing this. Knowing what is causing this error and how to fix it will be a great help.

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.

Forbidden when accessing image/sticker urls in chat messages returned from Graph Api

I received "Forbidden" when accessing an image/sticker link in a chat message return from Microsoft Graph Api.
I received the following chat message from Graph Api (not all properties are not listed):
{
"body": {
"contentType": "html",
"content": "<div><div>Message 499\n<div><span><img src=\"https://graph.microsoft.com/beta/teams/82d87df3-b8bd-4bdc-9090-5f8666b32134/channels/19:baf66ad0b75f4656bf20ff5667fae565#thread.skype/messages/1562258187781/hostedContents/aWQ9eF8wLWN1cy1kOC0xYjlkYTQ2NzA1ZTI5YjA5N2QzMDgyZjc2ODZiYTlhMSx0eXBlPTEsdXJsPWh0dHBzOi8vdXMtYXBpLmFzbS5za3lwZS5jb20vdjEvb2JqZWN0cy8wLWN1cy1kOC0xYjlkYTQ2NzA1ZTI5YjA5N2QzMDgyZjc2ODZiYTlhMS92aWV3cy9pbWdv/$value\" width=\"250\" height=\"250\" style=\"vertical-align:bottom; width:250px; height:250px\"></span>\n\n</div>\n\n\n</div>\n</div>"
}
}
Then I tried to access the image link
GET https://graph.microsoft.com/beta/teams/82d87df3-b8bd-4bdc-9090-5f8666b32134/channels/19:baf66ad0b75f4656bf20ff5667fae565#thread.skype/messages/1562258187781/hostedContents/aWQ9eF8wLWN1cy1kOC0xYjlkYTQ2NzA1ZTI5YjA5N2QzMDgyZjc2ODZiYTlhMSx0eXBlPTEsdXJsPWh0dHBzOi8vdXMtYXBpLmFzbS5za3lwZS5jb20vdjEvb2JqZWN0cy8wLWN1cy1kOC0xYjlkYTQ2NzA1ZTI5YjA5N2QzMDgyZjc2ODZiYTlhMS92aWV3cy9pbWdv/$value
Headers:
Authorization: bearer [access_token]
The response was:
403 Forbidden
{
"error": {
"code": "Forbidden",
"message": "Forbidden",
"innerError": {
"request-id": "3143682e-4dd2-4057-ad83-e4d7fbf32b98",
"date": "2019-07-05T07:09:06"
}
}
}
Headers:
request-id: 3143682e-4dd2-4057-ad83-e4d7fbf32b98
client-request-id: 3143682e-4dd2-4057-ad83-e4d7fbf32b98
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Southeast Asia","Slice":"SliceC","Ring":"3","ScaleUnit":"001","RoleInstance":"AGSFE_IN_2","ADSiteName":"SEA"}}
Date: Fri, 05 Jul 2019 07:09:05 GMT
However, I was able to list the hosted contents of the same channel:
GET: https://graph.microsoft.com/beta/teams/82d87df3-b8bd-4bdc-9090-5f8666b32134/channels/19:baf66ad0b75f4656bf20ff5667fae565#thread.skype/messages/1562258187781/hostedContents
Headers:
Authorization: bearer [access_token]
Response
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#teams('82d87df3-b8bd-4bdc-9090-5f8666b32134')/channels('19%3Abaf66ad0b75f4656bf20ff5667fae565%40thread.skype')/messages('1562258187781')/hostedContents",
"#odata.count": 1,
"value": [
{
"id": "aWQ9eF8wLWN1cy1kOC0xYjlkYTQ2NzA1ZTI5YjA5N2QzMDgyZjc2ODZiYTlhMSx0eXBlPTEsdXJsPWh0dHBzOi8vdXMtYXBpLmFzbS5za3lwZS5jb20vdjEvb2JqZWN0cy8wLWN1cy1kOC0xYjlkYTQ2NzA1ZTI5YjA5N2QzMDgyZjc2ODZiYTlhMS92aWV3cy9pbWdv"
}
]
}
Also, I was able to retrieve the image from another chat message in another channel (the general channel) in the same team.
GET https://graph.microsoft.com/beta/teams/82d87df3-b8bd-4bdc-9090-5f8666b32134/channels/19:db70de74054944fe9dbce0a592eddb6d#thread.skype/messages/1562252008138/hostedContents/aWQ9eF8wLWN1cy1kNi1iYWY0OTc0ZGNjMjc0MTAwMjI5YmMyZjcyY2Y0ODk2NSx0eXBlPTEsdXJsPWh0dHBzOi8vdXMtYXBpLmFzbS5za3lwZS5jb20vdjEvb2JqZWN0cy8wLWN1cy1kNi1iYWY0OTc0ZGNjMjc0MTAwMjI5YmMyZjcyY2Y0ODk2NS92aWV3cy9pbWdv/$value
Headers:
Authorization: bearer [access_token]
The user associated with the access token is one of the owners of the team, but he is not the one posting the chat message containing the image.
What am I missing here?
Update: I did more testing and found the following pattern.
The issue did not happen for General channel.
For other channels, if a user had not posted any message to a channel, accessing the image link of the chat messages resulted in Forbidden error. After the user posted one message, it could access the link fine.
Looks like a permission synchronization issue. Any idea?

When listing children of folder I get error 501 The request is not supported by the system

If I want to list files in the folder with query parameter $orderBy according to the documentation, I get a response with error 501.
Here is a raw example of request:
GET /v1.0/drives/{id}/items/{id}/children?$select=name,id,folder,lastModifiedDateTime,createdDateTime,size,createdBy,lastModifiedBy,webUrl&$orderby=createdDateTime HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer <token>
The response is:
{
"error": {
"code": "notSupported",
"message": "The request is not supported by the system.",
"innerError": {
"request-id": "c925ae56-8359-4e8f-98b9-92ff0c4dfc8a",
"date": "2018-06-04T10:50:00"
}
}
}
This problem I have only with a specific OneDrive account. If I use the same API call for a different drive and folder, then it works well without any problem.
When I investigated it then it seemed like the API doesn't support parameter $orderBy with date variable inside for this account at all.
Does anyone know why I get this error for a specific account?

Microsoft.Graph.createLink: 400 Version not specified

I'm trying to create a sharing link for OneDrive item using Microsoft.Graph.CreateLink action:
POST https://graph.microsoft.com/v1.0/me/drive/items/01B642VZR4QM6MX36HGZELNLHCFGY26JJ6/Microsoft.Graph.createLink HTTP/1.1
Authorization: Bearer {access_token}
Content-Type: application/json
{
"type":"edit"
}
and I got the following error:
HTTP/1.1 400 Bad Request
{
"error": {
"code": "BadRequest",
"message": "Version not specified.",
"innerError": {
"request-id": "3ca90464-3910-49e1-92f2-3a9daa822944",
"date": "2016-02-17T15:56:16"
}
}
}
Either method description or metadata does not contain any information about versions needed other than in the API endpoint.
From logs corresponding to request-id:3ca90464-3910-49e1-92f2-3a9daa822944, the request received by the service was "POST https://graph.microsoft.com/". The lack of path segment in the request URL is causing this expected error. Can you please check the request again?

Resources