Tab in channel is not able to open the file showing error "Sorry, this file has been deleted or moved" but file is present in Files

Anonymous
2022-07-26T08:04:08.8+00:00

Tab (Word/Excel/PowerPoint) in channel not able to open the file showing error "Sorry, this file has been deleted or moved" but the file is present in Files![224738-capture.jpg][1] [1]: /api/attachments/224738-capture.jpg?platform=QnA else if (tab.TeamsApp.Id == "com.microsoft.teamspace.tab.file.staticviewer.word" || tab.TeamsApp.Id == "com.microsoft.teamspace.tab.file.staticviewer.excel" || tab.TeamsApp.Id == "com.microsoft.teamspace.tab.file.staticviewer.powerpoint" || tab.TeamsApp.Id == "com.microsoft.teamspace.tab.file.staticviewer.pdf") { int pFrom = tab.Configuration.ContentUrl.IndexOf("https://" + authDomain + "/sites/") + ("https://" + authDomain + "/sites/").Length; int pTo = tab.Configuration.ContentUrl.LastIndexOf("/Shared", StringComparison.OrdinalIgnoreCase); string firstString = tab.Configuration.ContentUrl.Substring(0, pFrom); string secondString = tab.Configuration.ContentUrl.Substring(pTo, tab.Configuration.ContentUrl.Length - pTo); tab.Configuration.ContentUrl = firstString + siteName + secondString; //GetPath and EntityId int getPos = tab.Configuration.ContentUrl.IndexOf("Shared Documents", StringComparison.OrdinalIgnoreCase) + ("Shared Documents").Length; var filePath = tab.Configuration.ContentUrl.Substring(getPos + 1, tab.Configuration.ContentUrl.Length - getPos - 1); DriveItem fileItem = null; fileItem = graphServiceClient.Groups[_CurrTeamId].Drive.Root.ItemWithPath(filePath).Request().GetAsync().Result; int start = fileItem.ETag.IndexOf("{") + 1; int end = fileItem.ETag.IndexOf("}", start); string entityId = fileItem.ETag.Substring(start, end - start); tab.Configuration.EntityId = entityId; } var newTab = new TeamsTab() { AdditionalData = new Dictionary<string, object> { { "******@odata.bind", $"https://graph.microsoft.com/"+graphVersion+$"/appCatalogs/teamsApps/" + tab.TeamsApp.Id} }, DisplayName = tab.DisplayName, Configuration = tab.Configuration, //SortOrderIndex = tab.SortOrderIndex, WebUrl = tab.WebUrl, Id = tab.Id }; var createTab = graphServiceClient.Teams[_CurrTeamId].Channels[_CurrChannelId].Tabs.Request().AddAsync(newTab).Result;

Microsoft Teams | Development
Microsoft Teams | Microsoft Teams for business | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Nivedipa-MSFT 3,646 Reputation points Microsoft External Staff Moderator
    2022-09-20T14:59:30.73+00:00

    Adding answer from comment section

    Previously https://learn.microsoft.com/en-us/graph/api/channel-post-tabs?view=graph-rest-1.0 initialization of mentioned parameters were enough

    but now we have to initialize these all {"fileType":"pptx","fileName":"Sir EXCH2007","driveId":"b!1Fz-lGUCtU6jc4GpVRnJgbQdDCOXd2dLpYgx62aum0DfWI-nOkbFT6UcAkPBKyfX","docId":"01NJD46FAMRC5GBN7FBBAYWVYKPEKW5Y7C","objectUrl":"https://netxyz.sharepoint.com/sites/pubteamfinaltest/Shared Documents/General/Sir EXCH2007.pptx","isPinnedTab":true}

    driveId

    docId

    objectUrl

    Thanks,
    Nivedipa


    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.