Product Attribute Options

    List all attribute's options 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/productsattributeoptions
      • 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 options; each object has the following properties:

    • id - the option's ID (numeric)
    • siteId - the site's ID (numeric)
    • groupId - the attribute's ID (numeric)
    • optionName - the option's name (string)
    • imagePath - the option's image path (string)

    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/productsattributeoptions",
        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": 81889,
          "siteId": 1767665,
          "groupId": 28369,
          "optionName": "Blue",
          "imagePath": "/img/tshirt-name-blue.jpg"
        },
        {
          "id": 81890,
          "siteId": 1767665,
          "groupId": 28369,
          "optionName": "Red",
          "imagePath": "/img/tshirt-name-red.jpg"
        },
        {
          "id": 81891,
          "siteId": 1767665,
          "groupId": 28370,
          "optionName": "Leather",
          "imagePath": null
        },
        {
          "id": 81892,
          "siteId": 1767665,
          "groupId": 28370,
          "optionName": "Cotton",
          "imagePath": null
        }
      ],
      "totalItemsCount": 4,
      "skip": 0,
      "limit": 10
    }

    Get an option'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/productsattributeoptions/[option_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 option's ID (numeric)
    • siteId - the site's ID (numeric)
    • groupId - the attribute's ID (numeric)
    • optionName - the option's name (string)
    • imagePath - the option's image path (string)

    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/productsattributeoptions/81889",
        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": 81889,
          "siteId": 1767665,
          "groupId": 28369,
          "optionName": "Blue",
          "imagePath": "/img/tshirt-name-blue.jpg"
    }

    Create an attribute's option

    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/productsattributeoptions
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • groupId - the attribute's ID, required (numeric)
    • optionName - the option's name, required (string)
    • imagePath - the option's image path (string)

    Response:

    HTTP/1.1 201 CREATED
    Location: /webresources/api/v3/sites/current/productsattribute
    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/productsattributeoptions",
        type: "POST",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        processData: false,
        data: JSON.stringify({
            "groupId": 28369,
            "optionName": "Option name",
            "imagePath": "/optionalPath/imageName.extension"
        })
    });
    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 an attribute's option

    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/productsattributeoptions/[option_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • optionName - the option's name (string)
    • imagePath - the option's image path (string)

    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/productsattributeoptions/81906",
        type: "PUT",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        processData: false,
        data: JSON.stringify({
            "optionName": "Option name",
            "imagePath": "/optionalPath/imageName.extension"
        })
    });
    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 an attribute's option

    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/productsattributeoptions/[option_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/productsattributeoptions/81906 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/productsattributeoptions/[option_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/productsattributeoptions/81906",
        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.

    Upload option image

    Upload images to an existing option.

    Request

    • Method: PUT
    • Path: /webresources/api/v3/sites/current/productsattributeoptions/[option-id]
    • Headers:
      • Authorization: This should contain the authorization token. Here is how to obtain the token.
      • Content-Type: application/octet-stream

    Note: In order to be uploaded, the image path must be previously set in imagePath field.

    WARNING: The request will overwrite any file found at the image path.

    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/productsattributeoptions/[option-id]",
    type: "PUT",  data: binary-file, processData: false, contentType: "application/octet-stream", headers: { "Authorization": BCAPI.Helper.Site.getAccessToken() } }); request.done(function(data) { console.log(data); }); 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.

    HTTP/1.1 204 No Content