GraphQL mutation for updating products is not working

im trying to implement a python script that will update every product's alt text image to a specific text. My code initially is this: import requests import json import re # Define your Shopify store's API key and password API_KEY = '88xxxxxxxxxxxxxxxxxxxxxxxxxxxxf' PASSWORD = '0xxxxxxxxxxxxxxxxxxxxxxxxxxxx4' API_TOKEN = 'shpat_xxxxxxxxxxxxxxxxxxxxxxx' SHOPIFY_DOMAIN = 'https://www.xxxx.yyyy/' # Define your Shopify store's GraphQL endpoint GRAPHQL_ENDPOINT = 'https://www.xxxx.yyyy/admin/api/2024-04/graphql' headers = { 'X-Shopify-Access-Token': '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', 'Content-Type': 'application/json', } # Define the mutation template mutation_template = """ mutation updateImageAltText($productId: ID!, $imageId: ID!, $newAltText: String!) { productImageUpdate(productId: $productId, image: {id: $imageId, altText: $newAltText}) { image { id altText } userErrors { field message } } } """ # Function to send the mutation def send_mutation(product_id, image_id, new_alt_text): # Prepare the mutation variables variables = { "productId": product_id, "imageId": image_id, "newAltText": new_alt_text } # Prepare the GraphQL request payload payload = { "query": mutation_template, "variables": variables } # Send the GraphQL mutation request response = requests.post(GRAPHQL_ENDPOINT, json=payload, headers=headers) # Check for successful response if response.status_code == 200: print(f"Alt text updated successfully for image {image_id}") else: print(f"Failed to update alt text for image {image_id}. Response: {response.text}") But when im executing the code even if it is successfull the updated are not seen. I have tried running a fetch query with graphql but im getting this response which is quite weird # GraphQL query query = """ query MyQuery { products(first: 50) { edges { node { id images(first: 1) { edges { node { id altText } } } } } } } """ # JSON payload payload = { "query": query } # Make the POST request response = requests.post(GRAPHQL_ENDPOINT, json=payload, headers=headers) # # Check if the request was successful if response.status_code == 200: # Parse the JSON response data = response.json() # print(json.dumps(data, indent=4)) else: print(f"Query failed to run with a status code {response.status_code}") print(response.text) -------------------------OUTPUT--------------------------- b'<html>\n <body>\n <noscript>\n <a href="https://accounts.shopify.com/oauth/authorize?client_id=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c&destination_uuid=4aa9e194-f056-4326-b911-141e3efda215&nonce=9ecd58f45954fd0d7d9e7b886e8a1231&prompt=merge&redirect_uri=https%3A%2F%2Fc6859c-2.myshopify.com%2Fadmin%2Fauth%2Fidentity%2Fcallback&response_type=code&scope=email%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly%20openid%20profile%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fbanking.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fmerchant-setup-dashboard.graphql%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshopify-chat.admin.graphql%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fflow.workflows.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Forganization-identity.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fmerchant-bank-account.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshopify-tax.manage&state=d20d4aa1e3781ba66b325f770fe4a923&ui_locales=en&ux=shop">Continue</a>\n </noscript>\n\n <script type="text/javascript" defer>\n window.location="https:\\/\\/accounts.shopify.com\\/oauth\\/authorize?client_id=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c\\u0026destination_uuid=4aa9e194-f056-4326-b911-141e3efda215\\u0026nonce=9ecd58f45954fd0d7d9e7b886e8a1231\\u0026prompt=merge\\u0026redirect_uri=https%3A%2F%2Fc6859c-2.myshopify.com%2Fadmin%2Fauth%2Fidentity%2Fcallback\\u0026response_type=code\\u0026scope=email%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly%20openid%20profile%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fbanking.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fmerchant-setup-dashboard.graphql%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshopify-chat.admin.graphql%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fflow.workflows.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Forganization-identity.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fmerchant-bank-account.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshopify-tax.manage\\u0026state=d20d4aa1e3781ba66b325f770fe4a923\\u0026ui_locales=en\\u0026ux=shop" ;\n </script>\n </body>\n</html>\n' What am i missing? Any ideas?

Comment (0)

You’ll be in good company