More in this section

Forums / Developing with Sitefinity / Remove a control from a page using the REST api

Remove a control from a page using the REST api

1 posts, 0 answered
  1. Kevin Brydon
    Kevin Brydon avatar
    3 posts
    11 Feb 2014
    27 Mar 2014
    Link to this post

    I have a question similar to one that was never fully resolved

    Using the Sitefinity REST API I would like to remove a specific control from all pages. Is there a way I can do this? What service can I use to get the controls on a particular page?

    Currently I can get all pages using the API but not all controls on the page.

        var requestUri = "";
        var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(requestUri);
        request.ContentType = "application/json";
        request.Headers["wrap_access_token"] = myAccessToken;
        request.Method = "GET";

        var response = (System.Net.HttpWebResponse)request.GetResponse();

        MyNamespace.ItemCollection<MyNamespace.Page> pages;
        using (var reader = new System.IO.StreamReader(response.GetResponseStream(), Encoding.UTF8))
            using (var stream = new System.IO.MemoryStream(Encoding.UTF8.GetBytes(reader.ReadToEnd())))
                var pagesSerializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(MyNamespace.ItemCollection<MyNamespace.Page>));
                pages = (MyNamespace.ItemCollection<MyNamespace.Page>)pagesSerializer.ReadObject(stream);


        foreach (var page in pages.Items)
            // this is where I would loop though all the controls within the page and delete those of a specific type
1 posts, 0 answered