This tutorial is intended for view on larger devices.
This tutorial explains how to use the REST API to batch update products in your product catalog. You cannot add new products or archive old products with this call. Results of these updates do not trigger email notifications or the creation of a new record in Bronto on the Product Import History page. You will however see changes represented in the Products Search results.
Before you can successfully use the API to update product data, the product must already exist in Bronto. You will need to have all of the fields data (field name : field value) for each product you want to import in order for the import to validate. Individual products updates will be rejected if they fail validation.
The code in this tutorial uses PHP version 5.3.23 and the following libraries. In order to use this example, as written, you will need to make sure your PHP environment has these libraries installed.
- cURL http://php.net/manual/en/book.curl.php
- JSON* http://php.net/manual/en/book.json.php
*These libraries are usually installed and enabled by default
Identify Your Catalog ID
You will need to pass the ID for your product catalog as part of the call. To find your catalog ID:
- Log into Bronto.
- Go to Tables->Products.
- Locate the Products API ID.
- Save the ID.
Setup Hallmonitor Client
If you haven’t already, you need to set up Hallmonitor in order to be able to authenticate and work with Bronto’s REST API. Hallmonitor is an OAuth 2.0 compliant service that is used to request and refresh access tokens for Bronto’s APIs. You must create a client key and client secret for Hallmonitor in order to authenticate with Hallmonitor and get an API token.
- In the Bronto platform, navigate to Home > Settings > Data Exchange.
- Under the REST Integrations section, click Create New Integration.
- Enter a Client Name.
- Select the appropriate client permissions.
- Click Save.
A client key (ID) and secret are generated and shown on the Data Exchange page. Save the the client key and client secret shown in the REST Integrations section of the Data Exchange page. You will use it in the next step to create an API token.
Get Authentication Token
This call returns an authentication token as well as a refresh token to be used once the access token expires. The access token expires after 1 hour. The refresh token expires after 30 days. You will need to use this token to access Bronto’s API.
Define Your Product Data
Provide your product catalog ID and a JSON array containing all the products you want to update.
The array must contain all the fields (field name : field value) the product already has represented in the product catalog. You cannot just pass the fields you want to update.
Use Token To Authenticate With Bronto’s API
Each request to the external API must include the following HTTP headers:
- Authorization header. The header value should specify a “Bearer” authorization scheme followed by a space and then the OAuth2 access token.
- Content type header set to application/json.
- Content length header set to the string length of your data.
Update Your Product(s)
Make the update using a PUT request.
A 403 Forbidden response will be returned if no authorization header is provided, if a scheme other than Bearer is specified, if the token is unknown/expired, or if the token has an insufficient scope to execute the request.
Check For a Response
Results of these updates do not trigger email notifications or the creation of a new record in Bronto on the Product Import History page. To see errors that have occurred with specific product updates, you must view the responses to the API calls.
Normal validation of the product field values will be applied, and individual products updates will be rejected if they fail validation. An array of String errors will be returned for each product that is not updated.