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

%3CLINGO-SUB%20id%3D%22lingo-sub-2145542%22%20slang%3D%22en-US%22%3EIs%20there%20any%20REST%20API%20for%20creating%20new%20Excel%20(.xlsx)%20file%20in%20OneDrive%20cloud%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2145542%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20create%20a%20new%20excel%20file%20in%20OneDrive%20with%20the%20below%20properties%20of%20the%20REST%20API%20call.%3C%2FP%3E%3CP%3EURL%3A%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2F%2Fv1.0%2Fme%2Fdrive%2Froot%2Fchildren%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2F%2Fv1.0%2Fme%2Fdrive%2Froot%2Fchildren%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EBody%3A%3C%2FP%3E%3CPRE%3E%7B%0A%20%20%20%20%22name%22%3A%20%22MyFile.xlsx%22%2C%0A%20%20%20%20%22file%22%3A%20%7B%7D%2C%0A%20%20%20%20%22%40microsoft.graph.conflictBehavior%22%3A%20%22rename%22%0A%7D%3C%2FPRE%3E%3CP%3EHeader%3A%20Content-Type%3Aapplication%2Fjson%3C%2FP%3E%3CP%3EWith%20the%20help%20of%20the%20above%20properties%2C%20I'm%20able%20to%20create%20the%20file%20in%20OneDrive.%20But%20it%20is%20created%20without%20size%20%26amp%3B%20If%20I%20try%20to%20open%20the%20workbook%20it%20says%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ECouldn't%20Open%20the%20Workbook%20Error%20The%20workbook%20cannot%20be%20opened.%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EBasically%2C%20whenever%20I%20create%20a%20new%20excel%20file%20from%20UI%20it%20has%20a%20default%20size%20of%207.81KB%20(Could%20be%20used%20for%20metadata%20of%20file).%3C%2FP%3E%3CP%3EI%20have%20taken%20reference%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fdriveitem-post-children%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fdriveitem-post-children%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%3C%2FA%3E%3C%2FP%3E%3CP%3EIs%20there%20anyone%20who%20knows%20how%20to%20resolve%20this%20issue%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
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