CategoriesClearAll Endpoint

Overview

If you ever have the need to delete all of the categories from your store, this is the right endpoint of the REST API to use.  Please note that this endpoint requires that you enable a higher level of permissions in the store administration.  Go to the API page of the Admin menu to enable it. 

Requirements

The following pre-requisites will be necessary to accomplish the goals of this article:

  • General understanding of REST and API’s
  • Understanding of C# and/or JavaScript
  • Visual Studio 2012 or newer

Getting Started

If you haven’t done so already, you’ll need to login on your Hotcakes website as an administrator or superuser (host user).  This endpoint requires that you enable a higher level of permissions in the API.  This is because the act of deleting or destroying all categories is such a dangerous thing to do.  You cannot restore the categories once they are deleted. 

Once you are in the store administration, go to the API page in the Admin menu.  Clicking the button to allow “clear all” operations will enable all of the “clear all” operations for 60 minutes.

Allow Clear All Operations in the API

CategoriesClearAll

This REST API endpoint allows you to permanently delete all categories from your store. 

Example URL

This is what the REST endpoint will look like if you are calling it using JavaScript.  See our REST API URL documentation for more information.

http://example.com/DesktopModules/Hotcakes/API/rest/v1/categories

HTTP Method

DELETE

Parameters

This method only requires that you pass your API key.

Return Values   

True – This will be returned if all categories were successfully deleted.

False – This will be returned if the categories cannot be deleted for any reason.

Example Code

The following code will allow you to successfully call this endpoint, provided that you have enabled it.

Project References

  • Hotcakes.CommerceDTO

Import Namespaces

  • Hotcakes.CommerceDTO.v1
  • Hotcakes.CommerceDTO.v1.Catalog
  • Hotcakes.CommerceDTO.v1.Client

 

string url = "http://example.com";
string key = "YOUR-API-KEY";

Api proxy = new Api(url, key);

ApiResponse<bool> response = proxy.CategoriesClearAll();
// your domain name
var url = "http://example.com"; 
// the path where the API is
var apiPath = "/DesktopModules/Hotcakes/API/rest/v1/";  
// endpoint as shown in the documentation
var endPoint = "categories";  
// get this from the store admin
var apiKey = "YOUR-API-KEY";

$(document).ready(function() {

    $.ajax({
        dataType: "json",
        url: url + apiPath + endPoint + "?key=" + apiKey,
        type: 'DELETE',
        success: function (data) {
            // do something
        },
        error: function(jqXHR, textStatus) {
            // do something else
        }
    });

});
{
	"Errors":[],
	"Content":true
}
Have more questions? Submit a request

Need More Help?

Do you need more assistance with this article? Please review your support options.