Product Attributes

    List all the product's attributes of a site

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/productsattributes
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    An array of the first 10 attributes; each object has the following properties:

    • id - the attribute's ID (numeric)
    • siteId - the site's ID (numeric)
    • productId - the product's ID (numeric)
    • groupName - the attribute's name(string)
    • fieldTypeId - the attribute's display type (integer)
      • 5 - Drop Down List
      • 6 - Check Box List
      • 7 - Radio List
    • mandatory - whether this attribute is required when adding the product to cart (boolean)
    • keepStock - whether this attribute is used to track stock (boolean)

    You can output additional fields to those listed above as default, see the API v3 Discovery APP for additional details.

    Accepts and returns JSON as Content-Type.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/productsattributes",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Sample response

    {
      "items": [
        {
          "id": 28369,
          "siteId": 17673665,
          "productId": 44405,
          "groupName": "Size",
          "fieldTypeId": 5,
          "mandatory": true,
          "keepStock": true,
        },
        {
          "id": 28370,
          "siteId": 17673665,
          "productId": 44405,
          "groupName": "Color",
          "fieldTypeId": 6,
          "mandatory": true,
          "keepStock": false,
        }
      ],
      "totalItemsCount": 2,
      "skip": 0,
      "limit": 10
    }

    Get an attribute's details

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/productsattributes/[attribute_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    Displays the details for an attribute as a JSON object

    • id - the attribute's ID (numeric)
    • siteId - the site's ID (numeric)
    • productId - the product's ID (numeric)
    • groupName - the attribute's name(string)
    • fieldTypeId - the attribute's display type (integer)
      • 5 - Drop Down List
      • 6 - Check Box List
      • 7 - Radio List
    • mandatory - whether this attribute is required when adding the product to cart (boolean)
    • keepStock - whether this attribute is used to track stock (boolean)

    Accepts and returns JSON as Content-Type.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/productsattributes/28370",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Sample response

    {
          "id": 28370,
          "siteId": 17673665,
          "productId": 44405,
          "groupName": "Color",
          "fieldTypeId": 6,
          "mandatory": true,
          "keepStock": false,
    }

    Create a product's attribute

    Request

    • Method: POST
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/productsattributes
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • productId - the product's ID, required (numeric)
    • groupName - the attribute's name (string)
    • fieldTypeId - the attribute's display type (integer)
      • 5 - Drop Down List
      • 6 - Check Box List
      • 7 - Radio List
    • mandatory - whether this attribute is required when adding the product to cart (boolean)
    • keepStock - whether this attribute is used to track stock (boolean)
      • can't be set true when fieldTypeId is 6
      • can't be set true when mandatory field is false

    Response:

    HTTP/1.1 201 CREATED
    Location: /webresources/api/v3/sites/current/productsattributes
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/productsattributes",
        type: "POST",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        processData: false,
        data: JSON.stringify({
            "productId": 951894,
            "groupName": "Attribute name"
        })
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Response

    Returns an empty body if successful or a detailed error message.

    Accepts and returns JSON as Content-Type.


    Edit a product's attribute

    Request

    • Method:PUT
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/productsattributes/[attribute_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • productId - the product's ID (numeric)
    • groupName - the attribute's name(string)
    • fieldTypeId - the attribute's display type (integer)
      • 5 - Drop Down List
      • 6 - Check Box List
      • 7 - Radio List
    • mandatory - whether this attribute is required when adding the product to cart (boolean)
    • keepStock - whether this attribute is used to track stock (boolean)
      • can't be set true when fieldTypeId is 6
      • can't be set true when mandatory field is false

    Response

    Returns an empty body if successful or a detailed error message.

    Accepts and returns JSON as Content-Type.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/productsattributes/28371",
        type: "PUT",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        processData: false,
        data: JSON.stringify({
            "productId": 6710935,
            "groupName": "Attribute_A",
            "fieldTypeId": 5,
            "mandatory": true,
            "keepStock": true
        })
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Delete a product's attribute

    Request

    • Method: DELETE
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/productsattributes/[attribute_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Request:

    DELETE /webresources/api/v3/sites/current/productsattributes/28371 HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    
    HTTP/1.1 204 NO CONTENT
    Location: /webresources/api/v3/sites/current/productsattributes/[attribute_ID]
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/productsattributes/28371",
        type: "DELETE", connection: "keep-alive",
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
    $('.output pre').html(JSON.stringify(msg, null, 2));
    console.log(msg);
    })
        request.fail(function(jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Response

    Returns an empty body if successful or a detailed error message.