Assets API returns 404 error when try to create a liquid file.

Assets API returns 404 error when try to create a liquid file.

ferdaus
Shopify Partner
13 0 1

I am using Laravel and kyon147/laravel-shopify package to create an app. When I wanted to create a liquid file through asset API, I got the below error. Let me know what is wrong.

  "exception"
      Client error: `PUT my-shop-domain/admin/api/2023-10/themes/161834598681/assets.json` resulted in a `404 Not Found`

 Controller Method:

 

    public function index()
    {
        /** @var IShopModel $shop*/
        $shop = Auth::user();
        $themes = $shop->api()->rest('GET', '/admin/api/2023-10/themes.json');

        $activeThemeId = '';

        foreach ($themes['body']['themes'] as $theme) {
            if ($theme['role'] === 'main') {
                $activeThemeId = $theme['id'];
            }
        }

        if ($activeThemeId) {

            $content = "test content";

            $liquidFile = [
                'asset' => [
                    'key' => 'templates/out-of-stock.liquid',
                    'value' => "test content"
                ]
            ];

            $response = $shop->api()->rest('PUT', '/admin/api/2023-10/themes/' . $activeThemeId . '/assets.json', $liquidFile);

            dd($response);
        }
    }

 

Reply 1 (1)

thiago_tns
Shopify Partner
2 0 1

I have the exact same issue right now.