Request Python GraphQl



我得到一个错误时,使这种类型的请求:

{'errors': [{'message': 'Variable "$input" of required type "AccountBindBankCardInput!" was not provided.', 'locations': [{'line': 1, 'column': 24}], 'extensions': {'code': 'BAD_USER_INPUT'}}]}

网站上的有效载荷数据如下:

我的有效负载看起来像:

payload = {"operationName": "CreateBinding",
"input": '{lang: "ru", domainSfx: "ru", templateTag: "desktop/form", returnPath: "https://id.yandex.ru/pay", regionId: 1}',
"query": "mutation CreateBinding($input: AccountBindBankCardInput!) {n  accountBindBankCard(input: $input) {n    statusn    urln    __typenamen  }n}"}

$input值需要在variables块中传递;参见graphql.org"通过http提供服务";页面(这种连接格式不是GraphQL规范的一部分)。其中,variables的值需要是一个结构化的JSON对象,而不是一个序列化的字符串。

假设您要在通过网络发送payload之前将其序列化为JSON,这应该看起来像:

payload = {
"operationName": "CreateBinding",
"variables": {
"input": {
"lang": "ru",
"domainSfx": "ru",
"templateTag": "desktop/form", 
"returnPath": "https://id.yandex.ru/pay", 
"regionId": 1
},
},
"query": """
mutation CreateBinding($input: AccountBindBankCardInput!) {
accountBindBankCard(input: $input) {
status
url
__typename
}
}
"""
}

最新更新