代码输出HTML而不是JSON
我有一段Python代码,里面我正在通过Tableau Online连接到"metadata/graphiql"
,然后写一个“查询”。我本来希望得到的是JSON格式的结果,但却收到了些HTML代码。
import requests
graphql_url = "https://<server-name>/metadata/graphiql"
metadata_query='''
query {
workbooks{
name
}
}'''
response=requests.post(graphql_url, json={'query':metadata_query})
print(response.content)
if response.status_code==200:
print(response.json())
else:
print('Error:',response.text)
我期待能得到metadata_query
的JSON输出。
1 个回答
0
确保“graphql_url”的位置是正确的,再次检查一下错误处理的响应代码(response.status_code)。