-1
Ich habe den Code unten Rechnung bestellen in magento 2,0kann nicht über Rest api Rechnung erstellen in magento 2.0
<?php
$adminUrl='http://xxxxx/index.php/rest/V1/integration/admin/token';
$ch = curl_init();
$data = array("username" => "xxxxx", "password" => "xxxxx");
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$token= json_decode($token);
$headers = array("Authorization: Bearer $token");
$requestUrl1='http://xxxxx/index.php/rest/V1/invoices';
$ch1 = curl_init();
$ch1 = curl_init($requestUrl1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result1 = curl_exec($ch1);
$result1= json_decode($result1);
print_r($result1);
?>
Es gab mir
{"message":"%fieldName is a required field.","parameters":{"fieldName":"entity"}}
Ist Ihr '$ Token' mit korrekten Werten? –
ja die bestellungen bestellungen api und post new product api funktionierten –