Is there any REST API for creating new Excel (.xlsx) file in OneDrive cloud

Occasional Visitor

I'm trying to create a new excel file in OneDrive with the below properties of the REST API call.

URL: https://graph.microsoft.com//v1.0/me/drive/root/children Body:

{
    "name": "MyFile.xlsx",
    "file": {},
    "@microsoft.graph.conflictBehavior": "rename"
}

Header: Content-Type:application/json

With the help of the above properties, I'm able to create the file in OneDrive. But it is created without size & If I try to open the workbook it says Couldn't Open the Workbook Error The workbook cannot be opened.

Basically, whenever I create a new excel file from UI it has a default size of 7.81KB (Could be used for metadata of file).

I have taken reference from https://docs.microsoft.com/en-us/graph/api/driveitem-post-children?view=graph-rest-1.0&tabs=http

Is there anyone who knows how to resolve this issue?

0 Replies