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

Copper Contributor

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?

3 Replies

@harshadpanmand I'm also facing the same issue. did you find any solution to it?

@ashishPersistent.
I did not found any solution.
One suggested solution I found was, keep empty file(Original file created from UI) at one directory and while creating new file just copy Original file.

Did you find a solution for this issue?