简体   繁体   中英

How to change Template ID of item Using Sitecore Api..?? Note- Only Using sitecore api

我正在使用sitecore Api创建和更新项目,我的要求是仅在Sitecore9.0.2中使用Sitecore API更新项目的templateid

First you need to find the template by it's path path after /sitecore/template , so for /sitecore/templates/common/folder template, you would need to write:

var yourNewTemplate = item.Database.Templates["common/folder"];

And then you just call ChangeTemplate method on your Sitecore item, eg:

item.ChangeTemplate(yourNewTemplate);

I do not think there is any such api available which can change the template however you can edit an item using OData sitecore apis but it does not accept any such parameter which can modify it's template.

https://doc.sitecore.com/developers/90/sitecore-experience-manager/en/the-restful-api-for-the-itemservice.html

Edit An Item

URL

/item/{id}?database&language&version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM