【问题标题】:GraphQL and Python - `No query string was presented` errorGraphQL 和 Python - `No query string was present` 错误
【发布时间】:2018-06-27 18:57:58
【问题描述】:

这是我要发送的内容:

query = {"query": "mutation { memberCreate ( email:'john.doe@example.com', fullName:'John Doe') { member { id username } } }"}

qb_request = requests.post("some_url",
                  headers={"Accept": "application/json",
                           "Authorization": "some_auth"
                           },
                           data=json.dumps(query))

我收到以下错误:

{u'errors': [{u'message': u'No query string was present'}]}

有什么问题?

【问题讨论】:

    标签: python graphql


    【解决方案1】:

    json.dumps 将 json 对象转换为字符串,并在您接受 application/json 的标头中。这是不兼容的。

    尝试做类似的事情:

    query = {"query": "mutation { memberCreate ( email:'john.doe@example.com', fullName:'John Doe') { member { id username } } }"}
    
    qb_request = requests.post("some_url",
                      headers={
                        "Accept": "application/json",
                        "Authorization": "some_auth"
                      },
                      data=query
                  )
    

    【讨论】:

      猜你喜欢
      • 2020-05-23
      • 1970-01-01
      • 2022-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-04
      • 2019-09-08
      • 2013-06-29
      相关资源
      最近更新 更多