{"errors":{"image":"Required parameter missing or invalid"}}' when trying to update an image's alt

al_rmx
New Member
5 0 0

Hello everyone,

I have this python script and im trying to update an image alt text. My code is this:

# Define the endpoint URL

# Define the new alt text
new_alt_text = "#title-variantSKU"

# Prepare the request body
body = {
    "image": {
        "position": 1,
        "admin_graphql_api_id": "gid://shopify/ProductImage/53245809295685",
        "id": 53245809295685,  # Include the image ID,
        "alt": '#title-#seren.earth-#variantSKU',
        "product_id": 9190309691717,
    }
}


# Send the PUT request
response = requests.put(endpoint, json=body, headers=headers)
print(response.status_code)
print(response.content)
# Check the response status
if response.status_code == 200:
    print(f"Alt text updated successfully for image 9190309691717")
else:
    print(f"Failed to update alt text for image 9190309691717. Response: {response.text}")
 
But im always getting this error. My header is:
headers = {
    'X-Shopify-Access-Token': 'xxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json',
}
 
400 b'{"errors":{"image":"Required parameter missing or invalid"}}' Failed to update alt text for image 9190309691717. Response: {"errors":{"image":"Required parameter missing or invalid"}}
 
What am i missing? Why is this happening?
Replies 0 (0)