我在发布GraphQL和Python请求时遇到了问题。在
我的功能如下:
def create(request):
access_token = 'REDACTED'
headers = {
"X-Shopify-Storefront-Access-Token": access_token
}
mutation = """
{
checkoutCreate(input: {
lineItems: [{ variantId: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC80", quantity: 1 }]
}) {
checkout {
id
webUrl
lineItems(first: 5) {
edges {
node {
title
quantity
}
}
}
}
}
}
"""
data = (requests.post('https://catsinuniform.myshopify.com/api/graphql', json={'mutation': mutation}, headers=headers).json())
print(data)
return render(request, 'Stock/create.html', { 'create': data })
我收到错误消息,说我的json响应中有一个错误的请求“bad\u request-Parameter Missing or Invalid”。在
即使发送的是一个变异,请求主体仍然应该包含一个查询属性,该属性的值应该是表示操作的字符串。“这两种查询都被非正式地称为“查询”。将您的请求更改为:
相关问题 更多 >
编程相关推荐