jeffdavies avatar image
jeffdavies asked Erick Ramirez edited

How do I use swagger with composite partition keys?

I'm getting an error message from Swagger when I try to read a specific record from a table. Here is my table definition:

USE jd;
CREATE TABLE customer (
    id uuid,
    name text,
    country text,
    state text,
    city text,
    PRIMARY KEY ((country, state, city) id)

Here is a screenshot of how I am querying my table. I'll paste in the URL of the specific call after this image:


Here is the curl command that swagger creates for me:

curl -X GET "" -H  "accept: application/json" -H  "X-Cassandra-Token: REDACTED"

And here is the response from swagger:

  "description": "not enough partition keys provided",
  "code": 400

Now I'm new to the Cassandra world, so I'm sure I'm not defining my partition keys correctly, but I don't know the correct format to use. Any help will be greatly appreciated.

- Jeff

screenshot-54.png (165.1 KiB)
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered Erick Ramirez commented

As the instruction on the UI suggests, you need specify composite keys by separating values with slashes like value1/value2/....

In your case you'll need to specify the primary key values in the UI as:

  • first item (partition key): US/CA/Santa Clara
  • second item (clustering key): db6a74fd-7655-49eb-9212-1c1e1eb7b619

I don't have an environment set up so I'm not able to test it right now. Please try it and let me know how you go. Cheers!

2 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

jeffdavies avatar image jeffdavies commented ·

Thank you for the clarification. Part of my problem is that I'm un-learning the RDBMS way of things. I came across a youtube tutorial that stressed how Cassandra tables were designed with a "query first" point of view. I changed my table structures and I have the REST API chugging along just fine.

0 Likes 0 ·
Erick Ramirez avatar image Erick Ramirez ♦♦ jeffdavies commented ·

All good. We're happy to help if you have any questions. Cheers!

0 Likes 0 ·