简体   繁体   English

使用Python API创建产品时未收到Shopify的响应

[英]Not Receiving a Response from Shopify When Creating a Product Using Python API

I am using the Python API to create a Product with 5 Variants. 我正在使用Python API创建具有5个变体的产品。 I have been successful in creating the product in the store, without issue. 我已经成功地在商店中创建了产品,没有任何问题。 The problem I have is once the product is created, I do not receive a response from Shopify. 我遇到的问题是一旦创建产品,就不会收到Shopify的回复。 Because of this, I receive an HttpException from the API in my server. 因此,我从服务器中的API接收到HttpException。

I can deal with this, but I need to be able to create the product and populate a form with the Variant IDs of the newly created product. 我可以解决这个问题,但是我需要能够创建产品并使用新创建的产品的变体ID填充表单。 I was attempting this via an Ajax call to initiate the server call to Shopify, but I have also tried a synchronous request to the server, and I still do not receive a response from Shopify. 我正在尝试通过Ajax调用来发起对Shopify的服务器调用,但是我也尝试了对服务器的同步请求,但仍然没有收到Shopify的响应。

The Product details are as follows: 产品详细信息如下:

custom_product = shopify.Product()
custom_product.product_type = 'Custom Shirt'
custom_product.body_html = '<strong>Custom Shirt</strong>'
custom_product.title = 'Custom Shirt'
variant1 = shopify.Variant(dict(price=0, option1='Small'))
variant2 = shopify.Variant(dict(price=0, option1='Medium'))
variant3 = shopify.Variant(dict(price=0, option1='Large'))
variant4 = shopify.Variant(dict(price=0, option1='Extra Large'))
variant5 = shopify.Variant(dict(price=0, option1='2XL'))
variant6 = shopify.Variant(dict(price=price, option1='Bundle'))
custom_product.variants = [variant1,variant2,variant3,variant4,variant5, variant6]
# create images for front and back
front_image = shopify.Image(attributes=dict(shot='front'))
front_id = front_shirt_model.key().id()
front_image.src = 'http://myurl.com/img/'+str(front_id)
back_image = shopify.Image(attributes=dict(shot='back'))
back_id = back_shirt_model.key().id()
back_image.src = 'http://myurl.com/img/'+str(back_id)
custom_product.images = [front_image, back_image]

success = custom_product.save()

I should also mention that I am using Django on Google App Engine. 我还应该提到我在Google App Engine上使用Django。 I have tried different alternatives such as using the requests Python library to create the request JSON objects and connections, among others. 我尝试了其他替代方法,例如使用请求Python库创建请求JSON对象和连接等。 Please let me know if there is something I have overlooked. 请让我知道我是否忽略了某些内容。 Thank you in advance for any help. 预先感谢您的任何帮助。

It looks like this is due to the Google App Engine imposing a http timeout which python normally doesn't have by default. 看来这是由于Google App Engine施加了HTTP超时,而python通常默认没有这个超时。

How to set timeout for urlfetch in Google App Engine? 如何在Google App Engine中为urlfetch设置超时? explains how to set the default timeout to the maximum of 60 seconds. 说明如何将默认超时设置为最大60秒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM