/// <summary> /// Item creation sample /// </summary> /// <para> /// Requires an authenticated data context /// </para> /// <para> /// The user must have create permissions on the parent /// </para> /// <param name="context">The context.</param> private static void CreateItemSample(AuthenticatedSitecoreDataContext context) { //Dictionary<string, string> fieldstoUpdate = new Dictionary<string, string>(); //fieldstoUpdate.Add("Sitemap Item Order", "test Value"); //var query = new SitecoreCreateQuery //{ // ItemId = "{CBC4876C-EBDD-4472-899B-DC09933E2ED7}", // Template = "{790F9670-EE94-40C4-8233-4168528341B7}", // Database = "master", // Name="test", // FieldsToUpdate = fieldstoUpdate, // FieldsToReturn = new List<string> // { // "Name", // "" // } //}; //Dictionary<string, string> fieldstoUpdate = new Dictionary<string, string>(); //fieldstoUpdate.Add("Sitemap Item Order", "test Value"); //fieldstoUpdate.Add("Sitemap Title", "test Value"); //var query = new SitecoreCreateQuery //{ // ItemId = "{CBC4876C-EBDD-4472-899B-DC09933E2ED7}", // Database = "master", // FieldsToUpdate = fieldstoUpdate, // Language = "en", // FieldsToReturn = new List<string> // { // "Name", // "Sitemap Title" // } //}; Dictionary <string, string> fieldstoUpdate = new Dictionary <string, string>(); fieldstoUpdate.Add("Sitemap Item Order", "test Value"); fieldstoUpdate.Add("Sitemap Title", "test Value"); LoadOptions loadOptions = new LoadOptions(); loadOptions.Database = "master"; string loadoption = SerializeManager.SerializeLoadOption(loadOptions); string dataSyncItem = string.Empty; var query = new SitecoreAdvanceCreateQuery(Mindtree.Sitecore.WebApi.Client.SitecoreQueryType.AdvanceCreate, Mindtree.Sitecore.WebApi.Client.ResponseFormat.Json) { ItemId = "{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}", Database = "master", loadOptions = loadoption, syncItem = dataSyncItem, RetainID = true, }; //Media Version Create Query //FileStream fs = new FileStream(@"C:\data\unnamed.gif", FileMode.OpenOrCreate); //Dictionary<string, string> fieldstoUpdate = new Dictionary<string, string>(); //fieldstoUpdate.Add("Width", "114"); //fieldstoUpdate.Add("Height", "114"); //fieldstoUpdate.Add("Alt", "Test File"); //var query = new SitecoreCreateVersionQuery //{ // Items = "{4989E299-AE7B-42D5-A030-DAB9B0FF564F}", // ItemId = "{4989E299-AE7B-42D5-A030-DAB9B0FF564F}", // Database = "master", // FieldsToUpdate = fieldstoUpdate, // MediaItemStream=fs, // Language = "en", // FieldsToReturn = new List<string> // { // "Size", // "Extention" // } //}; ISitecoreWebResponse response = context.GetResponse <SitecoreWebResponse>(query); if (response.StatusCode == HttpStatusCode.OK) { WriteResponseMeta(response); foreach (WebApiItem item in response.Result.Items) { Wl("path", item.Path); WriteFields(item); } } else { WriteError(response); } Nl(); }