400 Bad Request Fullfillments.json

400 Bad Request Fullfillments.json

1010101010
Shopify Partner
7 0 1

Getting 400 bad request when I try to post a fulfillment - any ideas? 

 

This is my body

 

{
   "fulfillment":{
      "line_items_by_fulfillment_order":{
         "fulfillment_order_id":XXXXXXXX,
         "fulfillment_order_line_items":[
            {
               "id":1XXXXXXXX,
               "quantity":1
            }
         ]
      },
      "tracking_info":{
         "number":"XXXXXXXXXXXXX",
         "url":"https:\/\/ups.com",
         "company":"UPS"
      },
      "notify_customer":true,
      "message":"Your items have been shipped."
   }
}

This is my request

 

 

function createFulfillmentCan($data){
  $client = new Client();
  $body = json_encode($data,true);

  try {
  $response = $client->request('POST', "https://xxxxxxxxx.myshopify.com/admin/api/2022-10/fulfillments.json", [
    
    'headers' => [
      'Content-Type' => 'application/json',
      'X-Shopify-Access-Token' => 'xxxx_XXXXXXXXXXXXXXXXXXXXX'
    ],
    'body' => $body
  ]

);
   if($response->getStatusCode() == 200){
    return true;
}

  } catch(\GuzzleHttp\Exception\RequestException $e){
    return false;
  }

 

 



Reply 1 (1)

JamesG
Shopify Staff
42 10 11

Hey @1010101010 

The docs say that the line_items_by_fulfillment_order field takes an array, rather than an object. 

 

Hope that helps,

JamesG | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog