Ok, I’ve found it. Many thanks. You were right, and the failiure whre some missing rights…
In the shopify Backend you can set rigths for fulfilment_order.
$shopiyfy_api = new shopify_api();
$order_id = 'xxxxxxxxxxxx';
$result =$shopiyfy_api->getFullfillmentOrders($order_id); // tuts nach gesetzter berechtigung
$fulfillment_order_id = $result->result->fulfillment_orders[0]->id;
$shopiyfy_api->createFullfillment($order_id, $fulfillment_order_id, '00340434698785000666');
public function getFullfillmentOrders($order_id)
{
$url = 'https://ecowello.myshopify.com/admin/api/2023-01/orders/' . $order_id . '/fulfillment_orders.json';
$result = $this->curl_connect($url);
return $result;
}
public function createFullfillment($order_id, $fullfillment_order_id, $tracking_id)
{
$url = 'https://ecowello.myshopify.com/admin/api/2023-01/fulfillments.json';
// $url = 'https://ecowello.myshopify.com/admin/api/2023-01/orders/fulfillments.json';
// "location_id"=>xxxxxxxxxx
$data = [
"fulfillment" => [
"message" => "Dat süht esu us, wie wenn dat Meldung erus jejange wör. Donnens misch anroofe!!!",
"notify_customer" => true,
"tracking_info" => [
"number" => $tracking_id,
"url" => "https://www.dhl.de/de/privatkunden/dhl-sendungsverfolgung.html?piececode=" . $tracking_id,
"company" => "DHL"],
"line_items_by_fulfillment_order" => [
[
"fulfillment_order_id" => $fullfillment_order_id
]
]
]
];
$result = $this->curl_connect($url, $data);
}
private function curl_connect($url, $postfields = false)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-Shopify-Access-Token: ' . $this->admin_api_access_token,
'User-Agent: hlag himself',
'Host: ' . $this->store
]);
if ($postfields !== false) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postfields));
}
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$retval = new stdClass();
$retval->result = json_decode(curl_exec($ch));
$retval->url = curl_getinfo($ch)['url'];
$retval->http_code = curl_getinfo($ch)['http_code'];
return $retval;
}