The RESTful API uploads products to a warehouse catalog. This developer's guide is intended for web developers with basic knowledge of PHP, Java, C# or other programming languages.
To upload products to warehouse catalog, use http://api.solvingmaze.com/catalog.
The following table summarizes the JSON input parameters.
| Parameter | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| warehouse | Warehouse ID where products are uploaded to. | ||||||||||||||||||
| key | The warehouse's secret API key. | ||||||||||||||||||
| items |
An array of associative arrays. Each associative array stores item attributes:
All attributes are optional except for SKU. If an item with the given SKU already exists in the warehouse catalog, then its attributes will be replaced by the attributes in the request. However, if the item does not already exist, then it will be added to the catalog. Furthermore, any missing attributes in the request will assume their default values. An example parameter value is:
[
{
"sku": "101",
"name": "Jacket",
"unitPrice": 25.40,
"weight": 0.7,
"weightUnit": "lb",
"rotatable": true,
"packable": true,
"dimensionUnit": "in",
"dimensions":
[
{
"length": 12,
"width": 11,
"height": 1,
},
{
"length": 10,
"width": 8,
"height": 2,
}
]
}
]
|
The JSON response consists of a status associative array with the following attributes:
| Attribute | Description |
|---|---|
| success | A boolean flag indicating whether upload was successful. |
| messages | In the case of failure, an array of status messages may be returned. |
The following example uploads an item to a warehouse catalog. If the item already exists in the catalog, then its attributes will be replaced with the item attributes in the request.
<?php
$item = array(
'sku' => '101',
'name' => 'Shirt',
'unitPrice' => 10.75,
'weight' => 0.3,
'weightUnit' => 'lb',
'rotatable' => true,
'packable' => true,
'dimensionUnit' => 'in',
);
$dimensions = array();
$dimensions[] = array('length'=>11, 'width'=>9, 'height'=>1);
$item["dimensions"] = dimensions;
$params = array(
"warehouse" => json_encode($myWarehouseId),
"key" => json_encode($myApiKey),
"items" => json_encode(array($items)),
);
$ch = curl_init("http://api.solvingmaze.com/catalog");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>