12

I am creating keywords using the core service with the below code, the problem is I don't want to use a hardcoded TCM ID for the Category, as this may change between environments.

Is there any way to avoid this, as it appears you can't get a webdav path for Categories?

CategoryData category = (CategoryData)_coreService.Read("tcm:344-10060-512",  defaultReadOptions);

KeywordData keyword = (KeywordData)_coreService.GetDefaultData(ItemType.Keyword, category.Id);
keyword.Id = "tcm:0-0-0";
keyword.Title = value;
keyword.Key = key;

keyword = (KeywordData)_coreService.Create(keyword, _defaultReadOptions);

2 Answers 2

11

After running some test, it appears you can pass in a WebDav path to the Category, although the webdav path is in no means intuitive, it takes the format, /webdav/publication name/category name/

CategoryData category = (CategoryData)_coreService.Read("/webdav/publication name/category name/",  defaultReadOptions); 

thanks Ibrar Hussain for pointing me in the right direction

1
  • Glad to have been proven wrong :) I've done this with Folder creation, didn't think it was possible with Taxonomy! May 20, 2013 at 9:11
7

Just a little note on this one. If you wish to target the keywords themselves and not the category you will need to use the .tkw extension. The categories do not use any extension as shown in Pete's example. So for example (../20Parent%20Publication/Places/My%20Keyword.tkw). A good little trick to figure out some of these none intuitive extensions is to request the WebDavUrl based on the tcm id of the thing you are trying to get the path to. So in this case get the id of the categories and request the WebDavUrl.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.