Update Product SKUs - Fabric
Update Product SKUs
cURL
curl --request PUT \
--url 'https://api.fabric.inc/v3/products/sku?statuses=DRAFT%2CLIVE' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": [\
{\
"oldProductSku": "AAWE1234CCVFDDERW21",\
"newProductSku": "BQWE1234CCVFDDERW21"\
},\
{\
"oldProductSku": "AAWE1234CCVFDDERW20",\
"newProductSku": "BQWE1234CCVFDDERW20"\
}\
]
}
'```
### Python
```python
import requests
url = "https://api.fabric.inc/v3/products/sku?statuses=DRAFT%2CLIVE"
payload = { "data": [\
{\
"oldProductSku": "AAWE1234CCVFDDERW21",\
"newProductSku": "BQWE1234CCVFDDERW21"\
},\
{\
"oldProductSku": "AAWE1234CCVFDDERW20",\
"newProductSku": "BQWE1234CCVFDDERW20"\
}\
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)
JavaScript
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: [\
{oldProductSku: 'AAWE1234CCVFDDERW21', newProductSku: 'BQWE1234CCVFDDERW21'},\
{oldProductSku: 'AAWE1234CCVFDDERW20', newProductSku: 'BQWE1234CCVFDDERW20'}\
]
})
};
fetch('https://api.fabric.inc/v3/products/sku?statuses=DRAFT%2CLIVE', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
$curl = curl_init();
curl_setopt_array($curl, [\
CURLOPT_URL => "https://api.fabric.inc/v3/products/sku?statuses=DRAFT%2CLIVE",\
CURLOPT_RETURNTRANSFER => true,\
CURLOPT_ENCODING => "",\
CURLOPT_MAXREDIRS => 10,\
CURLOPT_TIMEOUT => 30,\
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
CURLOPT_CUSTOMREQUEST => "PUT",\
CURLOPT_POSTFIELDS => json_encode([\
'data' => [\
[\
'oldProductSku' => 'AAWE1234CCVFDDERW21',\
'newProductSku' => 'BQWE1234CCVFDDERW21'\
],\
[\
'oldProductSku' => 'AAWE1234CCVFDDERW20',\
'newProductSku' => 'BQWE1234CCVFDDERW20'\
]\
]\
]),\
CURLOPT_HTTPHEADER => [\
"Authorization: Bearer <token>",\
"Content-Type: application/json"\
],\
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fabric.inc/v3/products/sku?statuses=DRAFT%2CLIVE"
payload := strings.NewReader("{\n \"data\": [\n {\n \"oldProductSku\": \"AAWE1234CCVFDDERW21\",
\"newProductSku\": \"BQWE1234CCVFDDERW21\"\n },\n {\n \"oldProductSku\": \"AAWE1234CCVFDDERW20\",
\"newProductSku\": \"BQWE1234CCVFDDERW20\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Unirest
HttpResponse<String> response = Unirest.put("https://api.fabric.inc/v3/products/sku?statuses=DRAFT%2CLIVE")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"oldProductSku\": \"AAWE1234CCVFDDERW21\",
\"newProductSku\": \"BQWE1234CCVFDDERW21\"\n },\n {\n \"oldProductSku\": \"AAWE1234CCVFDDERW20\",
\"newProductSku\": \"BQWE1234CCVFDDERW20\"\n }\n ]\n}")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/products/sku?statuses=DRAFT%2CLIVE")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"oldProductSku\": \"AAWE1234CCVFDDERW21\",
\"newProductSku\": \"BQWE1234CCVFDDERW21\"\n },\n {\n \"oldProductSku\": \"AAWE1234CCVFDDERW20\",
\"newProductSku\": \"BQWE1234CCVFDDERW20\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body
Response Codes
- 200
- 400
- 401
- 403
- 409
- 413
- 500
Response Examples
Successful Response
{
"data": [\
{\
"success": [\
{\
"id": "AASSBCC12334FCD123346",\
"newSku": "BQWE1234CCVFDDERW21",\
"oldSku": "AAWE1234CCVFDDERW21"\
}\
],\
"errors": [\
{\
"id": "AASSBCC12334FCD123345",\
"newSku": "BQWE1234CCVFDDERW20",\
"oldSku": "AAWE1234CCVFDDERW20",\
"message": [\
"Attribute ID AASSBB123456IIII can not be null"\
]\
}\
]\
}\
]
}
Error Response
{
"message": "Request is invalid",
"type": "Bad request",
"errors": [\
{\
"type": "CLIENT_ERROR",
"message": "Invalid request. Unable to find or create product"\
}\
]
}
Other Errors
{
"type": "UNAUTHORIZED_ERROR",
"message": "The requester is unauthorized"
}
{
"type": "REQUEST_DENIED",
"message": "User doesn't have the required permission"
}
{
"type": "CONFLICT",
"message": "Unable to update as there is a conflict with a unique attribute.",
"errors": [\
{\
"type": "CONFLICT",
"message": "<ID> already exists"
}\
]
}
{
"type": "PAYLOAD_LIMIT_EXCEEDED_ERROR",
"message": "Payload exceeds maximum configured size"
}
{
"message": "Internal Server Error",
"type": "SERVER_ERROR"
}
Authorization
Header Parameters
- Authorization: S2S access token (JWT) from fabric Identity service required during Login.
- x-fabric-tenant-id: A header used by fabric to identify the tenant making the request. Must include tenant id in the authentication header. Example: 517fa9dfd42d8b00g1o3k312
- x-fabric-request-id: Unique request ID, e.g., "263e731c-45c8-11ed-b878-0242ac120002".
Body Parameters
Query Parameters
- statuses: Default: "DRAFT,LIVE"; specifies the preferred order of the product versions.