大家好!
关于这个主题:Run Data Explorer queries with the Discourse API - #27
我尝试将 CURL 命令移植到 Python,从语法角度看似乎没有问题,但我总是收到 404 错误,而运行 CURL 命令时却能收到 200。你们能帮我看看我哪里做错了吗?以下是我的 Python 代码:
# 导入
import requests
import json
# 常量
ENDPOINT = 'https://community.myCompanyName.com/admin/plugins/explorer/queries/73/run'
API_KEY = '<the_api_key>'
API_USERNAME = '<my_discourse_username>'
# 核心函数
def send_request(endpoint):
api_keys = {'Api-Key': API_KEY, 'Api-Username': API_USERNAME}
headers = {'Content-Type': 'multipart/form-data'}
request = requests.post(endpoint, api_keys, headers)
print("状态码:%s" % request.status_code)
send_request(ENDPOINT)
感谢帮助!