PUT
/products/:id/Update product
You can update a specific product.
| Attributes | Type | Required | Description |
|---|---|---|---|
| custom_id | string | no | A unique identifier for the product which is provided by the client. Usually related to the product’s SKU. |
| id | integer | yes | A unique identifier for the product which is given by User.com automatically. |
| brand_name | string | no | A brand name. |
| categories | integer(list) | no | A list of categories' ids. |
| city | string | no | An origin city of a product. |
| country | string | no | An origin country of a product. |
| created_at | datetime | no | A creation date of a product. |
| image_url | string | no | A URL of a product image. |
| name | string | no | A product name. |
| product_url | string | no | A URL of a product. |
| tags | string | no | A list of tags. |
| target_group | string | no | A name of a target |
| updated_at | datetime | no | A date of last product update. |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X PUT
"https://<your_app_subdomain>.user.com/api/public/products/:id/"
-H 'authorization: Token <your_64_char_api_key>'
-H 'content-type: application/json'
-d '{
"name": "updated product",
"custom_id": "my_product_id",
"product_url": "https://myshop.com/products/my_product/",
"image_url": "https://myshop.com/media/products/myproduct.jpg"
}'
var data = JSON.stringify({
"name": "updated product",
"custom_id": "my_product_id",
"product_url": "https://myshop.com/products/my_product/",
"image_url": "https://myshop.com/media/products/myproduct.jpg"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.#### ResponseText);
}
});
xhr.open("PUT", "https://<your_app_subdomain>.user.com/api/public/products/:id/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("accept", "*/*; version=2");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/products/:id/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\n\t\"name\": \"updated product\",\n\t\"custom_id\": \"my_product_id\",\n\t\"product_url\": \"https://myshop.com/products/my_product/\",\n\t\"image_url\": \"https://myshop.com/media/products/myproduct.jpg\"\n}",
CURLOPT_HTTPHEADER => array(
"Accept: */*; version=2",
"authorization: Token <your_64_char_api_key>",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests
url = "https://<your_app_subdomain>.user.com/api/public/products/:id/"
payload = "{\n\t\"name\": \"updated product\",\n\t\"custom_id\": \"my_product_id\",\n\t\"product_url\": \"https://myshop.com/products/my_product/\",\n\t\"image_url\": \"https://myshop.com/media/products/myproduct.jpg\"\n}"
headers = {
'authorization': "Token <your_64_char_api_key>",
'content-type': "application/json"
}
response = requests.request("PUT", url, data=payload, headers=headers)
print(response.text)
Response
{
"id": 50,
"name": "updated product",
"custom_id": "my_product_id",
"created_at": "2018-03-02T14:14:05.608704Z",
"updated_at": "2018-03-02T14:14:05.608742Z",
"product_url": "https://myshop.com/products/my_product/:id/",
"image_url": "https://myshop.com/media/products/myproduct.jpg",
"attributes": [],
"categories": []
}