Shopify Order Fulfilment using API

$url = 'https://' . $STORE_URL . '/admin/api//2023-07/fulfillments.json'; 
$ch = curl_init();

$abc = '{
"fulfillment": {

"line_items_by_fulfillment_order": [
{
"fulfillment_order_id": 5404222980327

}
],
"notify_customer" => false,
"tracking_info": {
"number": "MS1562678",
"url": "https://www.my-shipping-company.com?tracking_number=MS1562678"
},
"location_id": 71680327911
}
}';

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $abc);

$headers = array();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "X-Shopify-Access-Token: {$accessToken}"));

$results = curl_exec($ch);
//$results=json_encode($results);
$results=json_decode($results,true);

$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //can check status code, requst successfully processed if return 200
var_dump($http_code);
var_dump($results);

if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}

curl_close($ch);

this is my code I’m getting int(400) NULL error or sometimes 404 not found error while trying to fulfill the order.

Hi ZMahmood,

In the code above I noticed you have two slashes in the endpoint path (it should be /admin/api/2023-07/fulfillments.json) also there could be an issue with how you’re using the PHP array syntax (=>) inside a JSON string. It should be : instead of => for notify_customer. Can you retry with these changes?

the main issue was with my JSON data which I was trying to pass

here below is the right format which works for me.

$data = [
‘fulfillment’ => [
‘line_items_by_fulfillment_order’ => [
[
‘fulfillment_order_id’ => 6488664834279
]
],
‘notify_customer’ => false,
‘location_id’ => 69471600871
]
];