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);
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

| improve this answer | |
  • Glad to have been proven wrong :) I've done this with Folder creation, didn't think it was possible with Taxonomy! – Ibrar Hussain May 20 '13 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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