【发布时间】:2017-04-06 05:05:00
【问题描述】:
这里有什么问题?
query='{ repositoryOwner(login : "ALEXSSS") { login repositories (first : 30){ edges { node { name } } } } }'
headers = {'Authorization': 'token xxx'}
r2=requests.post('https://api.github.com/graphql', '{"query": \"'+query+'\"}',headers=headers)
print (r2.json())
我有
{'message': 'Problems parsing JSON', 'documentation_url': 'https://developer.github.com/v3'}
但是下面这段代码可以正常工作
query1= '''{ viewer { login name } }'''
headers = {'Authorization': 'token xxx'}
r2=requests.post('https://api.github.com/graphql', '{"query": \"'+query1+'\"}',headers=headers)
print (r2.json())
我已尝试更改引号(从 " 变为 ' 或与 " 等等),但它不起作用。
【问题讨论】:
标签: python python-requests github-api graphql