Illustration Image

How to query a single row by primary key from Astra DB using HTTP Request node in n8n? [closed]

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?") — нужно?

Become part of our
growing community!
Welcome to Planet Cassandra, a community for Apache Cassandra®! We're a passionate and dedicated group of users, developers, and enthusiasts who are working together to make Cassandra the best it can be. Whether you're just getting started with Cassandra or you're an experienced user, there's a place for you in our community.
A dinosaur
Planet Cassandra is a service for the Apache Cassandra® user community to share with each other. From tutorials and guides, to discussions and updates, we're here to help you get the most out of Cassandra. Connect with us and become part of our growing community today.
© 2009-2023 The Apache Software Foundation under the terms of the Apache License 2.0. Apache, the Apache feather logo, Apache Cassandra, Cassandra, and the Cassandra logo, are either registered trademarks or trademarks of The Apache Software Foundation. Sponsored by Anant Corporation and Datastax, and Developed by Anant Corporation.

Get Involved with Planet Cassandra!

We believe that the power of the Planet Cassandra community lies in the contributions of its members. Do you have content, articles, videos, or use cases you want to share with the world?