Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hey there @horatiu_j
Thanks for getting in touch! Would you mind sharing the body of the GraphQL query (with inputs) you are posting and any request_id's that you may have, and we can take a look. Thanks!
session = shopify.Session(self.shop_url, self.api_version, self.private_app_password)
shopify.ShopifyResource.activate_session(session)
query = '''
mutation productCreate($input: ProductInput!) {
productCreate(input: $input) {
product { id }
}
}
'''
variables = {"input": {
#"collectionsToJoin": "Sosuri",
# "collectionsToLeave": "",
"descriptionHtml": descriptionHtml,
# "giftCard": "",
# "giftCardTemplateSuffix": "",
"handle": "amestec-pentru-sos-de-brânză-cutie-1.2kg",
# "id": "",
# "images": {
# "altText": "",
# "id": "",
# "src": ""
# },
# "metafields": {
# "description": "",
# "id": "",
# "key": "",
# "namespace": "",
# "type": "",
# "value": ""
# },
# "options": "",
# "privateMetafields": {
# "key": "",
# "namespace": "",
# "valueInput": {
# "value": "",
# "valueType": ""
# },
# "owner": ""
# },
# "productPublications": {
# "channelHandle": "online store",
# "channelId": "",
# "publicationId": "",
# "publishDate": ""
# },
"productType": "Food",
# "publications": {
# "channelHandle": "",
# "channelId": "",
# "publicationId": "",
# "publishDate": ""
# },
# "publishDate": "",
# "publishOn": "",
# "published": "",
# "publishedAt": "",
# "redirectNewHandle": "",
# "requiresSellingPlan": "",
# "seo": {
# "description": "",
# "title": ""
# },
"status": "DRAFT",
"tags": "sos, Nannerl GmbH & Co KG, AUSTRIA, 6",
# "templateSuffix": "",
"title": "Amestec pentru Sos de BRÂNZĂ, cutie 1.2kg",
"variants": {
# "barcode": "",
"compareAtPrice": "219.10",
"fulfillmentServiceId": "gid://shopify/FulfillmentService/51943538763?id=true",
# "harmonizedSystemCode": "",
# "id": "",
# "imageId": "",
# "imageSrc": "",
"inventoryItem": {
# "cost": "191.50",
"tracked": True
},
# "inventoryManagement": "",
# "inventoryPolicy": "",
"inventoryQuantities": {
"availableQuantity": 6,
"locationId": "gid://shopify/Location/7587987514"
},
# "mediaSrc": "",
# "metafields": {
# "description": "",
# "id": "",
# "key": "",
# "namespace": "",
# "type": "",
# "value": ""
# },
# "options": "",
# "position": "",
"price": "191.50",
# "privateMetafields": {
# "key": "",
# "namespace": "",
# "valueInput": {
# "value": "",
# "valueType": ""
# },
# "owner": ""
# },
# "productId": "",
# "requiresShipping": "",
"sku": "SABUC628N",
# "taxCode": "",
# "taxable": "",
# "title": "",
"weight": 1.2,
"weightUnit": "KILOGRAMS"
},
"vendor": "ICELAND DISTRIBUTION"
}
}
print(variables)
create_product = shopify.GraphQL().execute(query, variables)
print(create_product)
shopify.ShopifyResource.clear_session()
# this is the script that I use and the respon is:
{"data":{"productCreate":{"product":null}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":990,"restoreRate":50.0}}}}
Thank you very much for your help L_J_K
The code is:
def create_product(self, descriptionHtml):
session = shopify.Session(self.shop_url, self.api_version, self.private_app_password)
shopify.ShopifyResource.activate_session(session)
query = '''
mutation productCreate($input: ProductInput!) {
productCreate(input: $input) {
product { id }
}
}
'''
variables = {"input": {
#"collectionsToJoin": "Sosuri",
# "collectionsToLeave": "",
"descriptionHtml": descriptionHtml,
# "giftCard": "",
# "giftCardTemplateSuffix": "",
"handle": "amestec-pentru-sos-de-brânză-cutie-1.2kg",
# "id": "",
# "images": {
# "altText": "",
# "id": "",
# "src": ""
# },
# "metafields": {
# "description": "",
# "id": "",
# "key": "",
# "namespace": "",
# "type": "",
# "value": ""
# },
# "options": "",
# "privateMetafields": {
# "key": "",
# "namespace": "",
# "valueInput": {
# "value": "",
# "valueType": ""
# },
# "owner": ""
# },
# "productPublications": {
# "channelHandle": "online store",
# "channelId": "",
# "publicationId": "",
# "publishDate": ""
# },
"productType": "Food",
# "publications": {
# "channelHandle": "",
# "channelId": "",
# "publicationId": "",
# "publishDate": ""
# },
# "publishDate": "",
# "publishOn": "",
# "published": "",
# "publishedAt": "",
# "redirectNewHandle": "",
# "requiresSellingPlan": "",
# "seo": {
# "description": "",
# "title": ""
# },
"status": "DRAFT",
"tags": "sos, Nannerl GmbH & Co KG, AUSTRIA, 6",
# "templateSuffix": "",
"title": "Amestec pentru Sos de BRÂNZĂ, cutie 1.2kg",
"variants": {
# "barcode": "",
"compareAtPrice": "219.10",
"fulfillmentServiceId": "gid://shopify/FulfillmentService/51943538763?id=true",
# "harmonizedSystemCode": "",
# "id": "",
# "imageId": "",
# "imageSrc": "",
"inventoryItem": {
# "cost": "191.50",
"tracked": True
},
# "inventoryManagement": "",
# "inventoryPolicy": "",
"inventoryQuantities": {
"availableQuantity": 6,
"locationId": "gid://shopify/Location/7587987514"
},
# "mediaSrc": "",
# "metafields": {
# "description": "",
# "id": "",
# "key": "",
# "namespace": "",
# "type": "",
# "value": ""
# },
# "options": "",
# "position": "",
"price": "191.50",
# "privateMetafields": {
# "key": "",
# "namespace": "",
# "valueInput": {
# "value": "",
# "valueType": ""
# },
# "owner": ""
# },
# "productId": "",
# "requiresShipping": "",
"sku": "SABUC628N",
# "taxCode": "",
# "taxable": "",
# "title": "",
"weight": 1.2,
"weightUnit": "KILOGRAMS"
},
"vendor": "ICELAND DISTRIBUTION"
}
}
print(variables)
create_product = shopify.GraphQL().execute(query, variables)
print(create_product)
shopify.ShopifyResource.clear_session()
# and the respons is:
{"data":{"productCreate":{"product":null}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":990,"restoreRate":50.0}}}}
Thank you very much for your help L_J_K.