我有一个问题,与此处发布的问题非常相似(但有所不同):https://meta.discourse.org/t/dataexplorer-missing-parameter-when-running-data-explorer-queries-with-params-via-api/223812。
我在 Data Explorer 中的查询如下所示:
-- [params]
-- topic_id :topic_id
SELECT * FROM posts WHERE topic_id = :topic_id
这在 Data Explorer 中运行正常。然后,当我尝试通过 API 运行它时,我会收到:
{"success":false,"errors":["DiscourseDataExplorer::ValidationError: Missing parameter topic_id of type topic_id"]}
这是我的 Python 请求:
headers = {
'Content-Type': 'multipart/form-data;',
'Api-Key': API_KEY,
'Api-Username': USERNAME_SYSTEM
}
params = {"topic_id": 398}
response = requests.post(url="[REDACTED]/admin/plugins/explorer/queries/10/run", headers=headers, params=params)
我从错误中推断出,我不能将“topic_id”作为字符串传递,但我不知道如何以其他方式将其作为键传递。有什么想法吗?
