enable assets

Topic summary

A developer is encountering a 404 error while attempting to enable assets in Shopify using the Admin API.

Technical Approach:

  • Using PHP with cURL to interact with Shopify’s Theme Assets API (version 2024-04)
  • Attempting to GET config/settings_data.json from a specific theme
  • Planning to modify block settings and PUT the updated configuration back

Current Issue:

  • Receiving HTTP 404 errors on API requests
  • The developer has verified their credentials and parameters but the error persists

Code Structure:
The implementation follows a two-step process:

  1. Fetch current settings via GET request
  2. Update settings via PUT request with modified block configuration

Status: The issue remains unresolved with no responses or solutions provided yet. The 404 suggests potential problems with the shop domain, theme ID, access token permissions, or API endpoint formatting.

Summarized with AI on October 30. AI used: claude-sonnet-4-5-20250929.

we are to trying like this to enable assetes but getting 404 ?
$shopifyDomain = “your-domain”;
$accessToken = “your-access-tocken”;
$themeId = “your-themid”;
$assetKey = “config/settings_data.json”;
$blockIdToEnable = “your block id”; // Block ID to modify

// 1. GET current settings_data.json
$getUrl = “https://$shopifyDomain/admin/api/2024-04/themes/$themeId/assets.json?asset[key]=$assetKey”;

$ch = curl_init($getUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
“X-Shopify-Access-Token: $accessToken”,
“Content-Type: application/json”
]
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

// Check if GET request was successful
if ($httpCode !== 200) {
die(“Error fetching current settings: HTTP $httpCode\n” . curl_error($ch));
}

// Decode response to get settings data
$assetData = json_decode($response, true);
if (!isset($assetData[‘asset’][‘value’])) {
die(“Error: settings_data.json not found or no value returned.”);
}

// Decode settings_data.json content
$settings = json_decode($assetData[‘asset’][‘value’], true);

// 2. Verify if the block ID exists before modifying
if (isset($settings[‘current’][‘blocks’][$blockIdToEnable])) {
$settings[‘current’][‘blocks’][$blockIdToEnable][‘disabled’] = false; // Enable block (set to false)
} else {
die(“Block ID $blockIdToEnable not found in theme settings.”);
}

// 3. Prepare PUT request data
// PUT request URL
$putUrl = “https://$shopifyDomain/admin/api/2024-04/themes/$themeId/assets.json”;

// Prepare the PUT payload
$putData = [
‘asset’ => [
‘key’ => $assetKey,
‘value’ => json_encode($settings, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)
]
];

// Initialize cURL for PUT request
$ch = curl_init($putUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => “PUT”,
CURLOPT_POSTFIELDS => json_encode($putData),
CURLOPT_HTTPHEADER => [
“X-Shopify-Access-Token: $accessToken”,
“Content-Type: application/json”
]
]);

// Execute PUT request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($httpCode === 200) {
echo “Successfully updated app embed settings.\n”;
} else {
echo “Error updating settings: HTTP $httpCode\n”;
print_r(json_decode($response, true));
}

curl_close($ch)

I varified these changes still getting 404 not found