Answer the question
In order to leave comments, you need to log in
How to make an online calculation through the TC Energy API?
It is not possible to carry out an online calculation of the shipment through the API ( apidoc.nrg-tk.ru/v3/ru ) An
error response is received
stdClass Object
(
[code] => InvalidJson
[message] => Invalid json
[extraInfo] => stdClass Object
(
[fieldMustBeType] => []api.CargoItem
[fieldValue] => object
)
)
$data = array(
"idCityFrom" => (int)$kem,
"idCityTo" => (int)$code,
"cover" => 0,
"idCurrency" => 0,
"items" =>["weight"=>10.2,"width"=>0.39,"height"=>0.39,"length"=>0.54],
"declaredCargoPrice" => 0,
"idClient" => 0
);
$json = json_encode($data);
$url = ('https://mainapi.nrg-tk.ru/v3/price');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "NrgApi-DevToken: Token"));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$obj = json_decode($result);
{
"idCityFrom": 3842,
"idCityTo": 343,
"cover": 0,
"idCurrency": 0,
"items": [
{
"weight": 10.0,
"width": 0.39,
"height": 0.39,
"length": 0.54
}
],
"declaredCargoPrice": 0,
"idClient": 0
}
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'NrgApi-DevToken: token' -d '{ \
"idCityFrom": 3842, \
"idCityTo": 343, \
"cover": 0, \
"idCurrency": 0, \
"items": [ \
{ \
"weight": 10.0, \
"width": 0.39, \
"height": 0.39, \
"length": 0.54 \
} \
], \
"declaredCargoPrice": 0, \
"idClient": 0 \
}' 'https://mainapi.nrg-tk.ru/v3/price'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question