# How to run Data Explorer queries with Python

**URL:** <https://meta.discourse.org/t/how-to-run-data-explorer-queries-with-python/145803>\
**Category:** Data & reporting\
**Tags:** rest-api\
**Created:** [March 27, 2020, 12:19pm UTC](https://meta.discourse.org/t/how-to-run-data-explorer-queries-with-python/145803 "2020-03-27T12:19:26Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Konrad\_Sopala](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/konrad_sopala/32/167014_2.png) [@Konrad\_Sopala](https://meta.discourse.org/u/Konrad_Sopala)\
**Post date:** [March 27, 2020, 12:19pm UTC](https://meta.discourse.org/t/how-to-run-data-explorer-queries-with-python/145803/1 "2020-03-27T12:19:27Z")

</div>

Hey there!

Regarding this topic: [Run Data Explorer queries with the Discourse API - #27](https://meta.discourse.org/t/how-to-run-data-explorer-queries-with-the-discourse-api/120063/27)

I tried to ported the CURL command to Python and from the syntax perspective everything seems ok but I’m getting 404 all the times but when I run. the CURL command I receive 200. Can any of you guys spot what I’m doing wrong? Here’s my Python code:

```plaintext
# 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)

```

Thanks for help!

---

_[View the full topic](https://meta.discourse.org/t/how-to-run-data-explorer-queries-with-python/145803)._
