首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Python API创建产品时未收到来自Shopify的响应

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

Stack Overflow用户
提问于 2012-12-22 13:58:35
回答 1查看 607关注 0票数 2

我正在使用Python API创建一个具有5个变体的产品。我已经成功地在商店中创建了产品,没有任何问题。我遇到的问题是,一旦创建了产品,我就没有收到来自Shopify的响应。正因为如此,我从我的服务器中的应用程序接口接收到一个HttpException。

我可以处理这个问题,但我需要能够创建产品并使用新创建的产品的变体ID填充表单。我试图通过一个Ajax调用来启动对Shopify的服务器调用,但是我也尝试了一个对服务器的同步请求,但我仍然没有收到来自Shopify的响应。

产品详情如下:

代码语言:javascript
复制
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。我尝试过不同的方法,比如使用requests Python库创建请求JSON对象和连接等。如果有什么疏忽的地方,请告诉我。提前感谢您的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-24 01:56:43

看起来这是因为Google App Engine设置了一个http超时,而python通常没有默认超时。

How to set timeout for urlfetch in Google App Engine?介绍了如何将默认超时设置为最大值60秒。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14000483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档