payload = """ query GetOrders($num_els: Int, $created_at: String, $cursor: String) {
orders(first: $num_els, query: $created_at, after: $cursor) {
edges {
node{
email
}
}
}
}"""
我尝试发送一个简单的查询。$cursor
字段可以为空。
variables = {'num_els': num_elements, 'created_at': f'created_at:>2022-01-10', 'cursor': None}
r = requests.post(constants['SHOPIFY_URL'], headers=headers,
json={'query': payload, 'variables': variables}).json()
然而,这给了我
[{'message': 'Parse error on "query" (STRING) at [1, 2]', 'locations': [{'line': 1, 'column': 2}]}]
即使我放弃了$created_at
中有点复杂的部分,问题仍然存在。你有什么建议吗?
将Content-Type
更改为application/json
,如所示