Search code examples
c#excelmicrosoft-graph-apimicrosoft-graph-sdks

Anonymous editable link doesn't allow edit an excel file


I want to create an editable anonymous link for an Excel file from SharePoint document library. As per the documentation Microsoft Graph C# SDK, I should be able to use createLink API with this code.

var driveItem = await graphClient.Drive
                    .Items[itemId]
                    .CreateLink("edit", "anonymous", null, null, null)
                    .Request()
                    .PostAsync();

return driveItem.Link.WebUrl;

But with the created link I can only view the excel file. The link does not allow editing the excel file. How can I create the link for the excel file?

Also, the same code working with MS Word files.

I am using Share Point Document Library and calling the APIs via Microsoft graph explorer.


Solution

  • If you have that excel document in sharepoint document library you should give the siteid,driveid and then itemid in you code, something like this.

    graphClient.Sites["siteid"]
        .Drives["documentlibraryid"]
        .Items["itemId"]                     
        .CreateLink("edit", "anonymous", null, null, null)
        .Request()                     
        .PostAsync();
    

    This way I was able to edit the excel file without logging as anonymous. I had also tested it in POSTMAN which also worked perfectly.

    enter image description here