1

I am trying to make use of the following Microsoft Graph API endpoint to add an extension to a .pptx file:

POST https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{item-id}/extensions
Content-Type: application/json
Authorization: Bearer {access-token}

{
    "@odata.type": "microsoft.graph.openTypeExtension",
    "extensionName": "CountMetadata",
    "count":1 
}

On calling this API, I am getting a 400 bad request error with the following details:

{
    "error": {
        "code": "invalidRequest",
        "message": "[openExtension] The specified type named microsoft.graph.openTypeExtension is not recognized.",
        "innerError": {
            "date": "{date}",
            "request-id": "{req-id}",
            "client-request-id": "{client-req-id}"
        }
    }
}

I tried the extensions API on /me endpoint. It works there. Can anyone explain the reason for this behavior?

I tried using the API on drive items and was expecting it to create an extension but it didn't work

1 Answer 1

0

Open extensions for driveItem are supported only in beta version.

Do not include @odata.type in the request body and ensure that the extension name starts with lower case.

POST https://graph.microsoft.com/beta/drives/{drive-id}/items/{item-id}/extensions
Content-Type: application/json
Authorization: Bearer {access-token}

{
    "extensionName": "countMetadata",
    "count":1 
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks user2250152 for providing an answer. I checked the behavior in the beta version as per your comments. It works in the beta version (still not sure why the "@odata.type" parameter is to be omitted to make it work though Microsoft has clearly stated to add this parameter while making the POST request).
I had another observation. If I make the POST call in the "1.0" version instead of the beta version in the same way as you mentioned then also it creates the extension but throws an error (The Path property of ODataMessageWriterSetting.ODataUri must end with the navigation property which the contained elements being written belong to.). Not sure of this behavior as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.