How to query a single row by primary key from Astra DB using HTTP Request node in n8n?
Hi everyone,
I am integrating Astra DB with n8n and need help with a specific use case.
✅ I can successfully get all rows from my host_checked
table with the following GET request:
GET https://81a80da2-9560-4b07-86f3-d9ad9d6dd0ec-us-east-2.apps.astra.datastax.com/api/rest/v2/keyspaces/contacts_keyspace/tables/host_checked/rows
Result: working fine — returns full list of records.
However, now I want to query only a single row where the primary key host = perkasamedical.com
.
I tried two methods:
1. GET by primary key
GET https://81a80da2-9560-4b07-86f3-d9ad9d6dd0ec-us-east-2.apps.astra.datastax.com/api/rest/v2/keyspaces/contacts_keyspace/tables/host_checked/rows/perkasamedical.com
Result:
❌ Bad request - Table 'tables' not found (in keyspace 'contacts_keyspace')
2. POST to /rows/query
POST https://81a80da2-9560-4b07-86f3-d9ad9d6dd0ec-us-east-2.apps.astra.datastax.com/api/rest/v2/keyspaces/contacts_keyspace/tables/host_checked/rows/query
Headers:
Content-Type: application/json
X-Cassandra-Token: <MY_TOKEN>
Body:
{
"where": {
"host": {
"eq": "perkasamedical.com"
}
}
}
Result:
❌ 405 Method Not Allowed
or
❌ Bad request - 'where' must be provided
Current setup:
- Database: Astra DB Serverless
- Table:
host_checked
- Primary Key:
host
- Authentication:
X-Cassandra-Token
- Platform: n8n (self-hosted on Google Cloud, Debian 12)
- Tested with: n8n HTTP Request node and curl
Example of my curl
request:
curl -X POST "https://81a80da2-9560-4b07-86f3-d9ad9d6dd0ec-us-east-2.apps.astra.datastax.com/api/rest/v2/keyspaces/contacts_keyspace/tables/host_checked/rows/query" \
-H "Content-Type: application/json" \
-H "X-Cassandra-Token: MY_TOKEN" \
-d '{
"where": {
"host": {
"eq": "perkasamedical.com"
}
}
}'
Result: 405 Method Not Allowed
❓ Question:
How can I correctly query just one row by its primary key (host
) using Astra DB REST API inside an n8n HTTP Request node?
Or should I use another method, like Document API instead?
Thank you very much for your help!
✅ Теперь ты можешь просто скопировать этот текст и вставить в поле "Body" на StackOverflow. Хочешь, я ещё сразу подготовлю краткий заголовок для поста? 🚀 (например: "How to query a single row by primary key from Astra DB REST API?") — нужно?