Add a component to a product (kit)
curl --request POST \
--url https://api.example.com/products/{productId}/components \
--header 'Content-Type: application/json' \
--data '
{
"componentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"quantity": 2,
"lossPercentage": 5.5,
"isMainItem": false,
"displayInDescription": true,
"affectsPrice": true
}
'import requests
url = "https://api.example.com/products/{productId}/components"
payload = {
"componentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"quantity": 2,
"lossPercentage": 5.5,
"isMainItem": False,
"displayInDescription": True,
"affectsPrice": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
componentId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
quantity: 2,
lossPercentage: 5.5,
isMainItem: false,
displayInDescription: true,
affectsPrice: true
})
};
fetch('https://api.example.com/products/{productId}/components', 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.example.com/products/{productId}/components",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'componentId' => 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
'quantity' => 2,
'lossPercentage' => 5.5,
'isMainItem' => false,
'displayInDescription' => true,
'affectsPrice' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/products/{productId}/components"
payload := strings.NewReader("{\n \"componentId\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"quantity\": 2,\n \"lossPercentage\": 5.5,\n \"isMainItem\": false,\n \"displayInDescription\": true,\n \"affectsPrice\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}HttpResponse<String> response = Unirest.post("https://api.example.com/products/{productId}/components")
.header("Content-Type", "application/json")
.body("{\n \"componentId\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"quantity\": 2,\n \"lossPercentage\": 5.5,\n \"isMainItem\": false,\n \"displayInDescription\": true,\n \"affectsPrice\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/products/{productId}/components")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"componentId\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"quantity\": 2,\n \"lossPercentage\": 5.5,\n \"isMainItem\": false,\n \"displayInDescription\": true,\n \"affectsPrice\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "exemplo_string",
"componentId": "exemplo_string",
"quantity": 123,
"lossPercentage": 123,
"isMainItem": true,
"displayInDescription": true,
"affectsPrice": true,
"unitCostSnapshot": 123,
"representationPercentage": 123,
"component": {}
}
Product Components
Add a component to a produto (kit)
Adds a SIMPLE product as a component of a KIT/MANUFACTURED product. Nested kits (adding a KIT as component of another KIT) are forbidden.
POST
/
products
/
{productId}
/
components
Add a component to a product (kit)
curl --request POST \
--url https://api.example.com/products/{productId}/components \
--header 'Content-Type: application/json' \
--data '
{
"componentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"quantity": 2,
"lossPercentage": 5.5,
"isMainItem": false,
"displayInDescription": true,
"affectsPrice": true
}
'import requests
url = "https://api.example.com/products/{productId}/components"
payload = {
"componentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"quantity": 2,
"lossPercentage": 5.5,
"isMainItem": False,
"displayInDescription": True,
"affectsPrice": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
componentId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
quantity: 2,
lossPercentage: 5.5,
isMainItem: false,
displayInDescription: true,
affectsPrice: true
})
};
fetch('https://api.example.com/products/{productId}/components', 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.example.com/products/{productId}/components",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'componentId' => 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
'quantity' => 2,
'lossPercentage' => 5.5,
'isMainItem' => false,
'displayInDescription' => true,
'affectsPrice' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/products/{productId}/components"
payload := strings.NewReader("{\n \"componentId\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"quantity\": 2,\n \"lossPercentage\": 5.5,\n \"isMainItem\": false,\n \"displayInDescription\": true,\n \"affectsPrice\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}HttpResponse<String> response = Unirest.post("https://api.example.com/products/{productId}/components")
.header("Content-Type", "application/json")
.body("{\n \"componentId\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"quantity\": 2,\n \"lossPercentage\": 5.5,\n \"isMainItem\": false,\n \"displayInDescription\": true,\n \"affectsPrice\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/products/{productId}/components")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"componentId\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"quantity\": 2,\n \"lossPercentage\": 5.5,\n \"isMainItem\": false,\n \"displayInDescription\": true,\n \"affectsPrice\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "exemplo_string",
"componentId": "exemplo_string",
"quantity": 123,
"lossPercentage": 123,
"isMainItem": true,
"displayInDescription": true,
"affectsPrice": true,
"unitCostSnapshot": 123,
"representationPercentage": 123,
"component": {}
}
Adds a SIMPLE produto as a component of a KIT/MANUFACTURED produto. Nested kits (adding a KIT as component of another KIT) are forbidden.
Parâmetros de Rota (Path)
Parâmetros da Requisição (Body)
Resposta de Sucesso
{
"id": "exemplo_string",
"componentId": "exemplo_string",
"quantity": 123,
"lossPercentage": 123,
"isMainItem": true,
"displayInDescription": true,
"affectsPrice": true,
"unitCostSnapshot": 123,
"representationPercentage": 123,
"component": {}
}
Body
application/json
Response
Component successfully added