MS Graph: Creating an excel Workbook

Mercy Muchai 1 Reputation point

I'd like to create an excel workbook. When running the POST endpoint to create a workbook:

I get a 400 as shown below

{ "error": { "code": "BadRequest", "message": "Resource not found for the segment 'workbooks'.", "innerError": { "date": "2022-08-22T11:39:32", "request-id": "c1a9e450-a7b0-4f78-bc4f-c270deaf60ac", "client-request-id": "dc021ab9-5c0b-f03c-76c0-b1f279225f0f" } } }.

The documentation for workbooks here does not also outline the endpoint and how to run the query.

Microsoft Graph Workbooks API
Microsoft Graph Workbooks API
A Microsoft API that allows web and mobile applications to read and modify Excel workbooks stored in OneDrive for Business, SharePoint site or Group drive.
62 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sheena-MSFT 1,711 Reputation points

    Hi @ MercyMuchai-8764,

    Currently it is not supported to create an excel workbook using workbook resource. It only allow reading and modifying workbook that are already exist.

    As a workaround you can create an empty excel using the following Graph query:


    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

  2. Mercy Muchai 1 Reputation point

    I'm not sure this created the workbook in the right format. When I run PUT, the workbook is created but cannot be opened due to this error.


    I observe it does not have any worksheets by default. Curious if the PUT should have a body that adds in some of that. Output when trying to create a new worksheet in it:

        "error": {  
            "code": "MetroFileFormatMismatch",  
            "message": "This workbook couldn't be opened because the file format may not be matching with the file extension.",  
            "innerError": {  
                "code": "unsupportedWorkbook",  
                "message": "The request failed. The workbook contains unsupported features or exceeds the size limit.",  
                "innerError": {  
                    "code": "MetroFileFormatMismatch",  
                    "message": "This workbook couldn't be opened because the file format may not be matching with the file extension."  
                "date": "2022-08-23T08:09:54",  
                "request-id": "**",  
                "client-request-id": "**"  

    When I try to manually open it, I get the same error: