Ecommerce Shopify WordPress Discussion

Shopify: Register products with HTML description using GraphQL

I'm new to Shopify GraphQL and trying to register products through GraphQL and Python. I wrote a code as below but it returns an error. Products with only text can be registered but products with HTML are not registered. Using GCP, Theme: Debut import requests import json # Shopify API credentials shop_url = "ShopURL" access_token = "ACCESS TOKEN" # GraphQL mutation mutation = ''' mutation { productCreate(input: { title: "ProductCreateTest" descriptionHtml: "<img data-src="https://cdn.shopify.com/s/files/test.jpg?v=123456" alt=""><br><br><p>"doublequotes"</p>" variants: [ { price: 29.99 } ] images: [ { src: "https://example.com/image.jpg" } ] }) { product { id title } } } ''' # GraphQL API endpoint api_url = f"{shop_url}/admin/api/2023-07/graphql.json" # Headers with authentication headers = { "Content-Type": "application/json", "X-Shopify-Access-Token": access_token } # Send the GraphQL request response = requests.post(api_url, headers=headers, data=json.dumps({"query": mutation})) # Check for success or handle errors if response.status_code == 200: result = response.json() created_product = result.get("data", {}).get("productCreate", {}).get("product", {}) if created_product: product_id = created_product.get("id") print(f"Product created with ID: {product_id}") else: print("Error creating product") else: print(f"Error: {response.status_code}, {response.text}") When putting plain text on the descriptionHTML field, it works perfectly. So, I'm considering Escape doesn't work on HTML.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.