为了账号安全,请及时绑定邮箱和手机立即绑定

GraphQL 和 Python 与 JSon - 未转义字符的语法错误

GraphQL 和 Python 与 JSon - 未转义字符的语法错误

桃花长相依 2021-06-21 17:12:16
我正在尝试发布一个 GraphQL Mutation 并且遇到了一个我无法弄清楚的语法错误。我看到有一个关于转义/非转义字符的错误。我试过转义,双引号,单引号,没有引号。我似乎无法解决这个问题。代码下的回溯。# http headers for api callheaders = {    'accept': "application/json",    'content-type':"application/json",    'authorization': "bearer " + token,}# create inventory variable for mutation # will convert the csv to the json input in productioninventory:[{"supplier_id":24522,"supplier_part_number":"1-1002-9-SN","quantity_on_hand":5,"item_next_availability_date":"05-01-2018T00:00:00", "discontinued":true}]# payload of the json query to pass to the API#GraphQL Query to pull in Purchase Order Data payload = '''{"query":"mutation save_inventory($inventory: [inventoryInput]!) {  inventory {    save(inventory: $inventory, dry_run: true) {      handle    }  }}"}'''# send API call and assign response to variableresponse = requests.post(api_url, data=payload, headers=headers)错误我无法在下面弄清楚。  {"errors":[{"message":"Syntax Error GraphQL (1:1) Unexpected <EOF>\n\n1: \n   ^\n","category":"graphql","locations":[{"l    ine":1,"column":1}]}]}
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 90 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信