CatalogRoleFindByCategory Endpoint

Overview

Sometimes you just need to find a catalog role to do something unique with it.  This endpoint allows you to find all catalog roles in your store that are assigned to a category.

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

You should already have a project open and ready to accept code to allow you to use this REST API endpoint.  You should also have one or more product roles assigned to categories so that you can successfully find some.

CatalogRoleFindByCategory

This REST API endpoint allows you to find a collection of category roles in your store using the category ID.   

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://yourdomain.com/DesktopModules/Hotcakes/API/rest/v1/catalogroles/[BVIN]?key=[YOURKEY]&bytype=category&bvin=[BVIN]

HTTP Method

GET

Parameters

Parameter Description
bvin This is the unique ID or primary key of the category that you wish to find catalog roles for.

Returns

If successful, this endpoint will return a populated list of CatalogRoleDTO object in JSON format.  Otherwise, you should have one or more errors returned.  

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://YOURDOMAIN.COM";
string key = "YOUR-API-KEY";

Api proxy = new Api(url, key);

// specify the category ID that you wish to find catalog roles for
var categoryId = "FE186C61-1997-4AD9-BA27-F7962D29261D";

// call the API to find the matching catalog roles
ApiResponse<List<CatalogRoleDTO>> response = proxy.CatalogRoleFindByCategory(categoryId);
// your domain name
var url = "http://YOURDOMAIN.COM"; 
// the path where the API is
var apiPath = "/DesktopModules/Hotcakes/API/rest/v1/";  
// endpoint as shown in the documentation
var endPoint = "catalogroles";  
// get this from the store admin
var apiKey = "YOUR-API-KEY";

$(document).ready(function() {

    // specify the category ID that you wish to find catalog roles for
    var categoryId = "FE186C61-1997-4AD9-BA27-F7962D29261D";

    // call the API to find the matching catalog roles
    $.ajax({
        dataType: "json",
        url: url + apiPath + endPoint + "/" + categoryId + "?key=" + apiKey + "&bytype=category&bvin=" + categoryId,
        type: 'GET',
        success: function (data) {
            // do something
        },
        error: function (jqXHR, textStatus) {
           // do something else
        }
    });

});
{
   "Errors":[

   ],
   "Content":[
      {
         "CatalogRoleId":4,
         "RoleName":"Registered Users",
         "ReferenceId":"fe186c61-1997-4ad9-ba27-f7962d29261d",
         "RoleType":1
      }
   ]
}
Have more questions? Submit a request

Need More Help?

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