Getting an error when trying to create a new excel workbook.

Jalen Parham 0 Reputation points
2024-05-13T20:11:06.9133333+00:00

I am trying to use the Graph API to create a new Excel workbook. I keep finding this way to do it everywhere on the internet. But I keep getting this error.

POST https://graph.microsoft.com/v1.0/me/drive/root/children
{
  "file": {},
  "name": "test.xlsx",
  "@microsoft.graph.conflictBehavior": "rename",
}

But I keep getting this error.

{
    code: 'invalidRequest',
    message: 'Cannot create a file without content',
    innerError: {
      date: '2024-05-13T18:21:41',
      'request-id': 'f0c4bd63-3242-4988-8fe5-79ab181f7046',
      'client-request-id': 'f0c4bd63-3242-4988-8fe5-79ab181f7046'
    }
}

How is the API call supposed to work?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,836 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 37,786 Reputation points
    2024-05-14T09:54:44.0766667+00:00

    Hi @Jalen Parham

    The same API call works fine for me. Have you tested it in Postman?

    User's image

    Hope this helps.

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

    0 comments No comments

  2. Hitesh Pachipulusu - MSFT 320 Reputation points Microsoft Vendor
    2024-05-16T12:20:13.5+00:00

    Hello @Jalen Parham ,

    Using Graph Explorer, I am able to use the same Graph API call. I have noticed in the request body you have provided there is a comma (,) in the third line after the rename. Please remove that and run the query.

    User's image

    Hope this helps.

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

    0 comments No comments