Mottor API
Search…
⌃K

Создать товар

В этом разделе описан API метод для создания товара.

Создание товара

Описание

post
https://api.lpmotor.ru
/v1/shop/product

Примеры

CURL
PHP(CURL)
PHP(Guzzle)
JavaScript(Axios)
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X POST "https://api.lpmotor.ru/v1/shop/product" \
-d "{\"site_id\": 11111, \"name\": \"product name\", \"price\": 109.99, \"is_visible\": true}
<?php
$ch = curl_init();
$url = 'https://api.lpmotor.ru/v1/shop/product';
$data = [
'site_id' => $siteId,
'name' => 'product name',
'price' => 109.99,
'is_visible' => true,
];
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
[
'Host: api.lpmotor.ru',
'X-Api-User-Id: ' . $userId,
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
'Accept: application/json',
]
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$responseData = json_decode($result, true);
curl_close($ch);
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$data = [
'site_id' => $siteId,
'name' => 'product name',
'price' => 109.99,
'is_visible' => true,
];
$response = $client->post(
'/v1/shop/product',
[
'json' => $data,
]
);
$statusCode = $response->getStatusCode();
$responseData = json_decode((string)$response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 30000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.post("/v1/shop/product", {
site_id : 11111,
name : "products name",
price : 109.99,
is_visible : true,
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});