设置
我正在使用Shopify管理API Python库通过一个私有应用程序连接访问我们的商店。
GET请求工作正常,即product = shopify.Product.find(6514193137813)
检索产品数据。
问题
如果我想更新现有产品,则PUT请求不起作用。那是,
product.title = 'test123'
product.save()
返回一个Redirection: Response(code=302,...)
。
到目前为止
我已经检查过了,读写许可也开了。
然后,我在Shopify论坛上发现了这个问题:https://community.shopify.com/c/Shopify-APIs-SDKs/API-Fulfillment-Status-Code-302-Redirect/m-p/747383/highlight/true#,Shopify的工作人员哈森指出,Shopify阻止您在包含cookie的POST请求中使用hassain。
但由于他的声明是关于帖子请求,我不确定这是否相关。
如何使PUT请求工作?
发布于 2021-04-06 13:35:42
我遵循马尔科姆的评论,并使用他的请求代码成功地更新了产品,
import requests
payload = {
"product":{
"title":"My new title"
}
}
api_key = "xxxxx"
password="xxxxxx"
headers = {"Accept": "application/json", "Content-Type": "application/json"}
#send email to customer through events endpoint
r = requests.put("https://"+api_key+":"+password+"@MYSTORE.myshopify.com//admin/api/2021-01/products/{PRODUCT_ID}.json", json=payload, headers=headers)
print(r)
https://stackoverflow.com/questions/66354429
复制相似问题