Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

fulfillmentServiceId problem

fulfillmentServiceId problem

horatiu_j
Visitor
3 0 0
 
Hello
I want to create a new product with GraphQl API (using Python). When I add "fulfillmentServiceId": "gid://shopify/FulfillmentService/51943538763?id=true", the result is productCreate":{"product":null}}. If I delete this option the product is created. I check the permission and I have permission to read/write on product and Fulfillment services. Where am I wrong? Please help me. Thank you very much. 
Replies 3 (3)

Luke_K
Shopify Staff
402 66 103

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!

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
horatiu_j
Visitor
3 0 0
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

 
horatiu_j
Visitor
3 0 0
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.