`未为必需参数提供值:id`图形ql数据库中的错误 问题: 我正在尝试从加密货币交易所下载数据 API文档页面是,它允许您查看API的工作方式 因为我的主要编程语言是Python,所以我使用它来下载数据,但是我得到了以下错误消息。 {'errors':[
`未为必需参数提供值:id`图形ql数据库中的错误 问题:`未为必需参数提供值:id`图形ql数据库中的错误 问题: 我正在尝试从加密货币交易所下载数据 API文档页面是,它允许您查看API的工作方式 因为我的主要编程语言是Python,所以我使用它来下载数据,但是我得到了以下错误消息。 {'errors':[,python,graphql,Python,Graphql,`未为必需参数提供值:id`图形ql数据库中的错误 问题: 我正在尝试从加密货币交易所下载数据 API文档页面是,它允许您查看API的工作方式 因为我的主要编程语言是Python,所以我使用它来下载数据,但是我得到了以下错误消息。 {'errors':[{'locations':[{'line':0,'column':0}],'message':'没有为所需参数提供值:id'}]} 有人能告诉我如何修复这个错误来下载数据吗 这对我来说很奇怪,因为下面的代码工作起来没有问题。唯一的区别是查询
- 我正在尝试从加密货币交易所下载数据
- API文档页面是,它允许您查看API的工作方式
- 因为我的主要编程语言是Python,所以我使用它来下载数据,但是我得到了以下错误消息。
{'errors':[{'locations':[{'line':0,'column':0}],'message':'没有为所需参数提供值:id'}]}
- 有人能告诉我如何修复这个错误来下载数据吗
- 这对我来说很奇怪,因为下面的代码工作起来没有问题。唯一的区别是查询语句中的内容
编码前在操场中测试查询。。。使用变量,而不是字符串操作。。。在python中重新创建工作请求-比较网络请求bodies@xdam你能用另一种方式表达你的意见吗?我不明白你所说的“编码之前……使用变量”是什么意思。我有。。。在我的密码里?
import request
timestamp = 1607904000
graphql_endpoint = 'https://api.thegraph.com/subgraphs/name/perpetual-protocol/perp-position-subgraph'
headers = {"Content-Type": "application/json"}
fundingRateUpdatedEvent_query = """query {
fundingRateUpdatedEvent(first: 1000, orderBy:timestamp,orderDirection:asc, where:{timestamp_gt: %i}) {
id
amm
rate
underlyingPrice
timestamp
}}""" % (timestamp)
request_result = requests.post(graphql_endpoint, json={'query': fundingRateUpdatedEvent_query}, headers=headers)
if request_result.status_code == 200:
request_result.json()['data']['fundingRateUpdatedEvents']
else:
raise Exception(f"GraphQL query failed to run by returning code of {request.status_code}.")
timestamp = 1607904000
graphql_endpoint = 'https://api.thegraph.com/subgraphs/name/perpetual-protocol/perp-position-subgraph'
headers = {"Content-Type": "application/json"}
positionChanged_query = """query {
positionChangedEvents(first: 1000, orderBy:timestamp,orderDirection:asc, where:{timestamp_gt: %i}) {
id
trader
timestamp
amm
margin
positionNotional
exchangedPositionSize
fee
positionSizeAfter
realizedPnl
unrealizedPnlAfter
badDebt
liquidationPenalty
spotPrice
fundingPayment
}}""" % (timestamp)
request_result = requests.post(graphql_endpoint, json={'query': positionChanged_query}, headers=headers)
print(request_result)
if request_result.status_code == 200:
print(request_result.json())
request_result.json()['data']['positionChangedEvents']
else:
raise Exception(f"GraphQL query failed to run by returning code of {request.status_code}.")