private static void EncryptedCredentialsSample(AuthenticatedSitecoreDataContext context) { var query = new SitecoreItemQuery(SitecoreQueryType.Read) { ItemId = "{11111111-1111-1111-1111-111111111111}", QueryScope = new[] { SitecoreItemScope.Self } }; ISitecoreWebResponse response = context.GetResponse <SitecoreWebResponse>(query); if (response.StatusCode == HttpStatusCode.OK) { WriteResponseMeta(response); WebApiItem item = response.Result.Items[0]; Wl("path", item.Path); Nl(); } else { WriteError(response); } Nl(); }
/// <summary> /// Item deletion sample /// </summary> /// <para> /// Requires an authenticated data context /// </para> /// <para> /// The user must have delete permissions on the item /// </para> /// <param name="context">The context.</param> private static void DeleteQuerySample(AuthenticatedSitecoreDataContext context) { // WARNING: all items in the query scope and their descendants will be deleted // only items in the query scope count toward the response count var query = new SitecoreItemQuery(SitecoreQueryType.Delete) { ItemId = "{11111111-1111-1111-1111-111111111111}", QueryScope = new[] { SitecoreItemScope.Self }, Database = "web" }; ISitecoreWebResponse response = context.GetResponse <SitecoreWebResponse>(query); if (response.StatusCode == HttpStatusCode.OK) { WriteResponseMeta(response); Wl("deletion count", response.Result.Count); if (response.Result.ItemIds != null) { foreach (string id in response.Result.ItemIds) { Wl("id", id); } } } else { WriteError(response); } Nl(); }
private static void ItemQuerySample(SitecoreDataContext context) { var query = new SitecoreItemQuery(SitecoreQueryType.Read) { ItemId = "{11111111-1111-1111-1111-111111111111}", QueryScope = new[] { SitecoreItemScope.Self, SitecoreItemScope.Children } }; ISitecoreWebResponse response = context.GetResponse <SitecoreWebResponse>(query); if (response.StatusCode == HttpStatusCode.OK) { WriteResponseMeta(response); foreach (WebApiItem item in response.Result.Items) { Wl("path", item.Path); } } else { WriteError(response); } Nl(); }
/// <summary> /// Item updating sample using item id /// </summary> /// <para> /// Requires an authenticated data context /// </para> /// <para> /// The user must have write permissions on the item /// </para> /// <param name="context">The context.</param> private static void UpdateItemIdSample(AuthenticatedSitecoreDataContext context) { //var query = new SitecoreItemQuery(SitecoreQueryType.Update) //{ // ItemId = "{11111111-1111-1111-1111-111111111111}", // QueryScope = new[] // { // SitecoreItemScope.Self, // SitecoreItemScope.Children // }, // Database = "master", // FieldsToUpdate = new Dictionary<string, string> // { // { "Field Name", "Value" }, // { "{11111111-1111-1111-1111-111111111111}", "Value" } // }, // FieldsToReturn = new List<string> // { // "Field Name", // "{11111111-1111-1111-1111-111111111111}" // } //}; Dictionary <string, string> fieldstoUpdate = new Dictionary <string, string>(); fieldstoUpdate.Add("Sitemap Item Order", "test Value-1"); var query = new SitecoreItemQuery(SitecoreQueryType.Update) { ItemId = "{CBC4876C-EBDD-4472-899B-DC09933E2ED7}", Database = "master", Language = "en-US", ItemVersion = 4, FieldsToUpdate = fieldstoUpdate, FieldsToReturn = new List <string> { "Name", "" } }; 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(); }
/// <summary> /// Item updating sample using item id /// </summary> /// <para> /// Requires an authenticated data context /// </para> /// <para> /// The user must have write permissions on the item /// </para> /// <param name="context">The context.</param> private static void UpdateItemIdSample(AuthenticatedSitecoreDataContext context) { var query = new SitecoreItemQuery(SitecoreQueryType.Update) { ItemId = "{11111111-1111-1111-1111-111111111111}", QueryScope = new[] { SitecoreItemScope.Self, SitecoreItemScope.Children }, Database = "master", FieldsToUpdate = new Dictionary <string, string> { { "Field Name", "Value" }, { "{11111111-1111-1111-1111-111111111111}", "Value" } }, FieldsToReturn = new List <string> { "Field Name", "{11111111-1111-1111-1111-111111111111}" } }; 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(); }