How to add node to Structural Navigation CSOM?
I don't use taxonomy, i don't use automatically added pages or lists.
I end up on determining, that global navigation is StandardNavigationSource.PortalProvider . And i searched google, stackexchange, MSDN and PnP to find some example how to programatically modify nodes and come up with nothing :(
Maybe it can be done using web.Navigation.TopNavigationBar, but that contains different nodes than ones defined in structure and displayed in sharepoint :(
UPDATE: I tried modifying TopNavigationBar like this
NavigationNodeCreationInformation node = new NavigationNodeCreationInformation(); node.Title = "test program"; node.Url = "http://test3"; node.IsExternal = true; node.AsLastNode = true; NavigationNode nodeAdded = parentNode.Children.Add(node); clientContext.ExecuteQuery(); And it worked, but still TopNavigationBar collections contains nodes that are not displayed in Sharepoint or in structure navigation settings. How do i found out those nodes so i can ignore it when copying navigation?
Update 2: Well it added node with that code once, than i experimented with external urls etc. and i'm not able to add more nodes!
Update 3: After some more experimenting it seems to ignore HTTPS URLs, that is quite crazy, and also ignore relative URLs.
Update 4: So adding node with absolute path with https at start and then changing it to https in the update works.
I Still don't know how to determine which nodes are actually shown in global top navigation and which don't show programmatically.