Python으로 Data Explorer 쿼리 실행하는 방법

안녕하세요!

이 주제에 대해 말씀드립니다: Run Data Explorer queries with the Discourse API - #27

CURL 명령어를 Python으로 변환해 보았는데, 문법적으로는 모두 정상으로 보이지만 항상 404 에러가 발생합니다. 반면 CURL 명령어를 실행하면 200 응답을 받습니다. 혹시 제가 어디서 잘못하고 있는지 알아볼 수 있을까요? 제 Python 코드는 다음과 같습니다:

# Imports

import requests
import json

# Constants

ENDPOINT = 'https://community.myCompanyName.com/admin/plugins/explorer/queries/73/run'
API_KEY = '<the_api_key>'
API_USERNAME = '<my_discourse_username>'

# Core Functions

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("STATUS CODE: %s" % request.status_code)

send_request(ENDPOINT)

도움 주시면 감사하겠습니다!

API 자격 증명을 헤더에 포함해야 합니다.

headers = {'Content-Type': 'multipart/form-data', 'Api-Key': API_KEY, 'Api-Username': API_USERNAME}

실제 요청을 보낼 때는 다음과 같이 지정해야 할 수 있습니다:

requests.post(endpoint, headers=headers)

완벽해요, 잘 작동했어요! 도움을 주셔서 정말 감사합니다, @blake!