Hi, i normally call webservice api rest of Magento with php and pass into url Api Secret and token magento into Header.
Into post string i pass the json .
The HttpJob return Error with errorMessage empty.
I don't know where is the problem.
Thi is my php code:
This is my B4A code:
Into post string i pass the json .
The HttpJob return Error with errorMessage empty.
I don't know where is the problem.
Thi is my php code:
PHP:
<?php
$tokenMagento = "tokenMagentoSecret";
$tokenPartner = "mytokenSecret";
error_reporting(0);
$ch = curl_init("https://myurl...it/rest/V1/edico-partner-products/" . $tokenPartner);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/json", "Authorization: Bearer " . $tokenMagento));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
$dataToSend = [
"filters" => [
[
"field" => "sku",
"value" => "SCH00%",
"condition_type" => "like"
]
]
];
var_dump(json_encode($dataToSend));
echo "<br>";
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataToSend));
$result = json_decode(curl_exec($ch), true)[0];
var_dump($result);
$error = curl_error($ch);
var_dump($error);
if (!empty($error)) {
echo "Errore: " . PHP_EOL;
var_dump($error);
} else {
echo "<pre>";
print_r($result['items_count']);
echo "</pre><br>";
echo "<pre>";
print_r($result['error_message']);
echo "</pre><br>";
echo "<pre>";
print_r($result['products']);
echo "</pre><br>";
if (!empty($result['error_message'])) {
echo "Messaggio di Errore: " . PHP_EOL;
var_dump($result['error_message']);
}
}
curl_close($ch);
?>
This is my B4A code:
B4X:
Dim j As HttpJob
j.Initialize("",Me)
Dim job As HttpJob
Dim url As String = "https://myurl...it/rest/V1/edico-partner-products/tokenPartner/"
Dim json1 As Map
json1.Initialize
Dim filters As List
filters.Initialize
Dim field As Map
field.Initialize
field.Put("field","sku")
field.Put("condition_type","like")
field.Put("value","SCH00%")
filters.Add(field)
json1.Put("filters",filters)
Dim jgen As JSONGenerator
jgen.Initialize(json1)
Log(jgen.ToPrettyString(2))
Log(jgen.ToString)
j.PostString(url, jgen.ToString)
j.GetRequest.SetHeader("Authorization", "Bearer " & token)
j.GetRequest.SetContentType("application/json")