![](/img/trans.png)
[英]Creating a new product with image URL in shopify using its python api
[英]Not Receiving a Response from Shopify When Creating a Product Using Python API
我正在使用Python API创建具有5个变体的产品。 我已经成功地在商店中创建了产品,没有任何问题。 我遇到的问题是一旦创建产品,就不会收到Shopify的回复。 因此,我从服务器中的API接收到HttpException。
我可以解决这个问题,但是我需要能够创建产品并使用新创建的产品的变体ID填充表单。 我正在尝试通过Ajax调用来发起对Shopify的服务器调用,但是我也尝试了对服务器的同步请求,但仍然没有收到Shopify的响应。
产品详细信息如下:
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()
我还应该提到我在Google App Engine上使用Django。 我尝试了其他替代方法,例如使用请求Python库创建请求JSON对象和连接等。 请让我知道我是否忽略了某些内容。 预先感谢您的任何帮助。
看来这是由于Google App Engine施加了HTTP超时,而python通常默认没有这个超时。
如何在Google App Engine中为urlfetch设置超时? 说明如何将默认超时设置为最大60秒。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.