C# Http Method How to Upload Document into SharePoint Online Document Library
In this article we will see how to upload file into SharePoint Online Document Library using REST API and HTTP method. Also you will drr how to get the document ID of the same upload document. Here is the code: string filePath = @"C:\MyFile.pdf"; string siteUrl = "https://domainname.sharepoint.com/sites/contoso5/" byte[] bytefile = System.IO.File.ReadAllBytes(filePath); HttpWebRequest endpointReq = (HttpWebRequest)HttpWebRequest.Create(siteUrl + "/_api/web/GetFolderByServerRelativeUrl('DocLib/MyFolder')/Files/add(url='Myfile.pdf',overwrite=true)?$expand=ListItemAllFields"); endpointReq.Method = "POST"; endpointReq.Headers.Add("binaryStringRequestBody", "true"); endpointReq.Headers.Add("Authorizatio...