none
How to get Preview of a shared file in MS Graph client? RRS feed

  • Question

  • I m Using MS Graph Client and having a trouble of previewing Shared Items with me and downloading shared files to my folder.

    For the start i use graph asp,net snippets sample project and to preview my files  below code works fine . 
    ItemPreviewInfo preview = await graphClient.Me.Drive.Items[id].Preview().Request().PostAsync(); 
    But to preview and download shared files this is not working cos the item is not in my folder. 
    According to this Graph documentation https://docs.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0 

     i ve changed the code as 

    string base64Value = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ShareUrl));
                
    string encodedUrl = "u!" + base64Value.TrimEnd('=').Replace('/', '_').Replace('+', '-');          
            
    ItemPreviewInfo preview = await graphClient.Shares[encodedUrl].Items[id].Preview().Request().PostAsync();

    ShareUrl = Url of the shared item 
    id = id of the shared item  ( i also tried remote item Id too ) 

    but the response is  "Microsoft.SharePoint.Client.ResourceNotFoundException Cannot find resource for the request items."

    Can anyone please help me with this. Thank you . 

    Im Using MS Graph Client and having a trouble of previewing Shared Items with me.

     ItemPreviewInfo preview = await graphClient.Me.Drive.Items[id].Preview().Request().PostAsync(); 

    Im Using MS Graph Client and having a trouble of previewing Shared Items with me.

     ItemPreviewInfo preview = await graphClient.Me.Drive.Items[id].Preview().Request().PostAsync(); 

    Im Using MS Graph Client and having a trouble of previewing Shared Items with me.

     ItemPreviewInfo preview = await graphClient.Me.Drive.Items[id].Preview().Request().PostAsync(); 
    Monday, December 24, 2018 3:03 PM