Lately we encountered this issue of 411 Length required issue while trying to do POST / PUT request in shopify.

We are using this phpish Shopify private app skeleton

In this app skeleton we made changes in vendor/phpish/shopify/shopify.php inside client function


if (!$private_app) $request_headers['X-Shopify-Access-Token'] = $oauth_token;

$request_headers['content-type'] = 'application/json; charset=utf-8';

$data_query = http_build_query($response_headers);
$data_len = strlen($data_query);

$request_headers['Content-Length'] =$data_len;
$http_client = http\client($base_uri, $request_headers);

In above code we have added data length supplied as content length and that would solve this 411 length required error.
Cheers !!

Suman K.C

eCommerce Developer, writes about stuff related to eCommerce development. Currently based in Kathmandu, loves reading about startups & new technology, introvert nature, fond of traveling & playing futsal.

More Posts