work with Excel file using sharepoint document library using Microsoft Graph API RRS feed

  • Question

  • i am following

    I downloaded and customized this project. this is working fine without any issue with onedrive excel files/items. but i have to do this using office 365 sharepoint online only. 
    i am able to get file id using service point as follows:
      var serviceEndpoint = "";

    but i am not sure how should i define workbook end point url with sharepoint to update/manipulate same excel file data. current workbook end point url as follows(which is not working):
    var workbookEndpoint = "" + fileId + "/workbook";

    my complete method to update cell value in excel file on sharepoint as follows:

     public static async Task UpdateExcelCellValue_Sharepoint(string accessToken, string cellAddress, string val)
                string worksheetName = "Parameters";
                var serviceEndpoint = "";
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
                var filesResponse = await client.GetAsync(serviceEndpoint + "?$select=name,id");
                if (filesResponse.IsSuccessStatusCode)
                    var filesContent = await filesResponse.Content.ReadAsStringAsync();
                    JObject parsedResult = JObject.Parse(filesContent);
                    foreach (JObject file in parsedResult["value"])
                        var name = (string)file["id"];
                        if (name.Contains("173"))
                            fileId = (string)file["id"];
                    //Handle failed response
                //Set up workbook and worksheet endpoints
                var workbookEndpoint = "" + fileId + "/workbook";
                var worksheetsEndpoint = workbookEndpoint + "/worksheets";
                var patchMethod = new HttpMethod("PATCH");
                var summaryTableRowJson = "{" +
                        "'values': '" + val + ".csv'" +
                var colNamePatchBody = new StringContent(summaryTableRowJson);
                colNamePatchBody.Headers.Add("Content-Type", "application/json");
                var colNameRequestMessage = new HttpRequestMessage(patchMethod, worksheetsEndpoint +
                    "('" + worksheetName + "')/range(address='Parameters!B2')")
                { Content = colNamePatchBody };
                var colNameResponseMessage = await client.SendAsync(colNameRequestMessage);

    any help would be highly appreciated. 

    ravi anand don't believe in excuses

    Wednesday, August 16, 2017 1:33 PM

All replies

  • Hello,

    This forum is for Excel Object Model. As you are using Microsoft Graph API, I would move this thread into Office 365 for Developers forum.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, August 17, 2017 1:49 AM