This is series of blog articles showing how to clone Teams Channels and Tabs without using the Clone REST endpoint or direct REST queries. Except we use the Microsoft.Graph (3.1.0). First post discusses things in general, details about different tab types are separated to individual articles.
- Cloning Teams Channels and Tabs without /clone REST endpoint
- Cloning Planner Tab without /clone REST endpoint
- Cloning OneNote Tab without /clone REST endpoint <<YOU ARE HERE>>
- Cloning Web Tab without /clone REST endpoint (TBD)
- Copying Teams Files tab content using MoveCopyUtil
In this piece of code, we first determine current source tab is of type OneNote. We must first create new Notebook for the tab, and for this we add simple retry logic as you cannot have Notebooks with duplicate name. This retry logic adds running integer to Notebook name until the creation succeeds.
Now, after we have successfully created the Notebook, it is time to create the Tab. Do note the special format of the EntityId parameter for the tab, as well as rather identical URLs.
Finally, note that you may end up getting ServiceException although tab creation succeeds, thus the scary Exception swallowing.
Using term cloning when it comes to this tab type can be a bit misleading, as we’re not cloning the tab content, but only the tab and creating new content. Perhaps think of this as cloning from the Team perspective, while the individual tabs