Uploading Excel file to Sharepoint using Graph API can't open/corrupted.

Dreyo 0 Reputation points
2024-09-05T08:34:16.9466667+00:00

Endpoint: https://graph.microsoft.com/v1.0/drives/${driveID}/root:/${folder}/${filename}:/content

Content-Type: text/plain

Filename: Test.xlsx

I have an excel file with multiple sheets, i uploaded it to my system and should trigger the sharepoint upload.

The excel file was uploaded to sharepoint but when I open the sharepoint an error pops out:457506346_7565546366880715_6319208432792514952_n

This is how i converted excel file to Binary:

var file = document.getElementById("myFile").files[0];
var reader = new FileReader(); 
reader.onload = function(ev) { 
var array = ev.target.result;
var fileByteArray = [];
for (var i = 0; i < array.length; i++) {
	fileByteArray.push(array[i]); 
}
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,393 questions
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.