# Discourse Data Explorer SQL Query

**URL:** <https://meta.discourse.org/t/discourse-data-explorer-sql-query/357351>\
**Category:** Support\
**Tags:** data-explorer\
**Created:** [March 15, 2025, 1:26am UTC](https://meta.discourse.org/t/discourse-data-explorer-sql-query/357351 "2025-03-15T01:26:40Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![JohnMcDonald](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@JohnMcDonald](https://meta.discourse.org/u/JohnMcDonald)\
**Post date:** [March 15, 2025, 1:26am UTC](https://meta.discourse.org/t/discourse-data-explorer-sql-query/357351/1 "2025-03-15T01:26:40Z")

</div>

I have a question that is very similar to (but different from) the question posted here: [`DataExplorer::ValidationError: Missing parameter` when running Data Explorer queries with [params] via API](https://meta.discourse.org/t/dataexplorer-missing-parameter-when-running-data-explorer-queries-with-params-via-api/223812).

My query in [Data Explorer](https://meta.discourse.org/t/32566?silent=true) looks like this:

```plaintext
-- [params]
-- topic_id :topic_id

SELECT * FROM posts WHERE topic_id = :topic_id

```

This works fine in [Data Explorer](https://meta.discourse.org/t/32566?silent=true). Then, when I try and run it via the API I get:

```plaintext
{"success":false,"errors":["DiscourseDataExplorer::ValidationError: Missing parameter topic_id of type topic_id"]}'

```

Here is my python request:

```plaintext

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)

```

I gather from the error than I cannot pass “topic\_id” as a string, but I don’t see how else I can pass it as a key. Any thoughts on this?

---

_[View the full topic](https://meta.discourse.org/t/discourse-data-explorer-sql-query/357351)._
