Shopify Asset API Updating Collection.liquid Using PUT Method Giving 404 With CURL

- 1 answer

I am trying to update collection.liquid using Shopify API.
I am using below Shopify API wrapper with CodeIgniter,

Shopify API wrapper

This wrapper uses cURL to make API calls. I have used this library to make other apps for Shopify and it works just fine with GET,POST methods. For the first time I have tried using PUT method with it. and its giving me cURL Error given below
ERROR #22: The requested URL returned error: 404 Not Found"

    protected function modify_asset($theme_id)

       $data = array(
            'API_KEY' => $this->config->item('shopify_api_key'),
            'API_SECRET' => $this->config->item('shopify_secret'),
            'SHOP_DOMAIN' => $this->session->userdata('shop_domain'),
            'ACCESS_TOKEN' => $this->session->userdata('access_token')

        $this->load->library('shopify', $data);

        $fields = array(
            "asset" => array(

                "key" => "templates\/collection.liquid",
                "value" => "<p>We are busy updating the store for you and will be back within 10 hours.<\/p>"


        $args = array(

                 'URL' => '/admin/themes/163760333/assets.json',
                 'METHOD' => 'PUT',
                 'RETURNARRAY' => TRUE,
                 'DATA' => $fields

            $modification_response = $this->shopify->call($args);
            return $modification_response;

        catch(Exception $e){
            $modification_response = $e->getMessage();
            log_message('error','In Get Active Theme Id' . $modification_response);
            var_dump('In modification response ' . $modification_response);



Above is my function to implement the API call. You can see cURL options and its implementation on below link:
cURL options and happening of Shopify API call

Note : This request is working just fine on POSTMAN.



I've just been running some tests on this code using the information you provided, and was able to get a successful submission after removing the backslash in $fields['asset']['key'] as per the example above.


"key" => "templates\/collection.liquid",


"key" => "templates/collection.liquid",

It appears Shopify doesn't require forward slashes in file keys to be escaped.