I have a list containing managed meta data field which is reading data from following term store (picture given below):
I am trying to set field value using C# code as below but getting error
Error
Specified argument was out of the range of valid values.\r\nParameter name: index
TaxonomySession taxonomySession = new TaxonomySession(site);
TermStore termStore = taxonomySession.TermStores["Managed Meta Data"];
Group group = termStore.Groups["DemoGroup"];
TermSet termSet = group.TermSets["Contoso Departments"];
Term term = termSet.Terms["Finance"]; //error is on this line
If I change above line to following then it works fine. It seems since Finance is under Accounting so I cannot directly write its name and has to define some kind of path.
Term term = termSet.Terms["Accounting"]; //this line works fine
How do I update value of "Finance"?