How to upload CSV file via graph api

When we use Microsoft Graph to upload files, according to the official document, we can only upload TXT document sample. So how do we upload other types of documents?

Firstly, the Microsoft Graph API does not support the following file uploads:

  • .ashx – ASP.NET Web handler file
  • .asmx – ASP.NET Web Services source file
  • .json – JavaScript Object Notation file
  • .soap – Simple Object Access Protocol file
  • .svc – Windows Communication Foundation (WCF) service file
  • .xamlx – Visual Studio Workflow service file

Except the above types of files , other types are supported by Microsoft Graph API, the following details will be given how to upload CSV / XlSX type of file:


FolderAthe folder where you want to upload the file  FileB.csv: the name of the file

Method: Put

Permission:  Delegated     Files.ReadWrite, Files.ReadWrite.All, Sites.ReadWrite.All                                                                     Application   Files.ReadWrite.All, Sites.ReadWrite.All

Authentication:                                                                                                                                                      Post:/tenant-id/oauth2/token?api-version=1.0
Content-Type: application/x-www-form-urlencoded


Header: Content Type: application/ or text/csv

The Body section is especially noticeable here because CSV is in the form of a spreadsheet, so each cell in the Body should be separated by a comma, with the second line directly in the Body section if it is a newline. For example:
1a,11,7,fish                                                                                                                                                          2b,14,8,meat                                                                                                                                                           Result:                                                                                                                


In this article, I’ve demonstrated how to upload CSV file via graph API. Additionally, you can also upload the file types below as similar way. Chat with us  if you have any questions.

Suffix MIME Type
.doc application/msword
.dot application/msword
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
.docm application/
.dotm application/
.xls application/
.xlt application/
.xla application/
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.xlsm application/
.xltm application/
.xlam application/
.xlsb application/
.ppt application/
.pot application/
.pps application/

Leave a Reply

Your email address will not be published. Required fields are marked *