0

I want to update the content of the file on OneDrive item. For that I used this API.

PUT /drives/{drive-id}/items/{parent-id}:/{filename}:/content

This works perfectly fine for non China azure with Microsoft graph endpoint.

https://graph.microsoft.com

However, when I am trying this on AzureChina it is throwing me 501 error.

https://microsoftgraph.chinacloudapi.cn

Error:

This is the error response I am getting event though I am uploading data to file.

    {
    "error": {
        "code": "notSupported",
        "message": "Cannot upload content to an item representing a folder.",
        "innerError": {
            "date": "2021-05-10T09:01:12",
            "request-id": "98a8b075-bb90-42fe-8620-7303e669f4ec",
            "client-request-id": "98a8b075-bb90-42fe-8620-7303e669f4ec"
        }
    }
}

Is this not implemented in AzureChina? Another thing is graph explorer does not work with AzureChina. Is there separate graph explorer available for AzureChina?

2 Answers2

0

According to this page OneDrive and Excel features of Graph API are limited by Microsoft Cloud China but without more details what exactly is not supported.

user2250152
  • 14,658
  • 4
  • 33
  • 57
  • For me get items API is working for AzureChina. But not content API. I did found the Graph Explorer for AzureChina but looks like it is still in development. – Sanket Bhurke May 11 '21 at 05:52
0

For Azure China, Work around for Graph API is to use SharePoint REST API v1.

To upload the file contents of drive items

URL: https://{site_url}/_api/web/GetFolderByServerRelativeUrl('/Folder Name')/Files/add(url='newFile.txt',overwrite=true)
Headers:
"Accept": "application/json; odata=verbose",
"Authorization": "Bearer " + accessToken
Method: "POST",
Body:
<File_contents>

Auth URL: https://login.partner.microsoftonline.cn/{{TenantID}}/oauth2/v2.0/authorize

Access Token URL: https://login.partner.microsoftonline.cn/{{TenantID}}/oauth2/v2.0/token

Scope : https://{tenantId}-my.sharepoint.cn/.default

Make sure you have added appropriate API Permissions for SharePoint & granted Admin consent in Azure AD portal within corresponding Application.