"line_items":"expected Hash to be a Array" when trying to create fulfillment

Highlighted
New Member
1 0 1

Hi everyone.

I'm trying to send next params to /admin/api/2020-04/orders/{order_id}/fulfillments.json

Array
(
    [fulfillment] => Array
        (
            [location_id] => 47670722709
            [tracking_number] => 
            [line_items] => Array
                (
                    [0] => Array
                        (
                            [variant_id] => 34586053542037
                            [quantity] => 1
                        )

                )

        )

)

json {
"fulfillment" :{
"location_id" :47670722709,
"tracking_number" :null,
"line_items" : [
{
"id":5547874910357
}
]
}
}

and got next error  "line_items":"expected Hash to be a Array".

Have no idea why - doing exactly as in documentation

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillment?api[version]=...

 

could anyone help me please?

Highlighted
New Member
2 0 1

We are also having the same issue, and it seems over the past few weeks multiple people on the forums are also having this issue. Does anyone have any ideas? Is this an issue on the Shopify end?

Highlighted
New Member
1 0 0

hello,

you must to add in the curl headers the content type and the parameters as a json , this is a example in php :


$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_MAXREDIRS, 3);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_USERAGENT, 'My New Shopify App v.1');
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);

$request_headers[] = "";

$request_headers[] = "X-Shopify-Access-Token: " . $token;
$request_headers[] = "Content-Type: application/json" ;

curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($query) );

$response = curl_exec($curl);

 

 

0 Likes