Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

nadim avatar image
nadim asked Erick Ramirez edited

How do I fetch a specific row in Swagger UI with composite primary keys?

I know this question has been asked before here , but I followed the steps outlined and its not working for me!

I have uploaded, my table description along with the error and the Get Request that I'm sending!

Please let me know what I'm doing wrong!

I have tried using the console and it works perfectly, I have also attached a screen shot of this

Thank you for your help, let me know if you need more info? I'm stuck :((

screen-shot-2022-03-18-at-95050-pm.png

three.png

one.png

two.png

stargate
one.png (238.3 KiB)
two.png (202.4 KiB)
three.png (101.9 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 edited

I can't quite figure out from the info you posted which part you're having issues with so I'll use an example.

I have this table that contains movies:

CREATE TABLE community.movies (
    title text,
    release_year int,
    cast text,
    country text,
    date_added text,
    description text,
    director text,
    duration text,
    listed_in text,
    rating text,
    show_id int,
    type text,
    PRIMARY KEY ((title, release_year))
)

My table has a composite partition key:

    PRIMARY KEY ((title, release_year))

If I wanted to query the table using the Stargate REST API, I need to provide the partition key in the form title/release_year with a slash (/) as the delimiter. Here is an example API call using curl:

$ curl -X 'GET'
    -H 'accept: application/json'
    -H 'X-Cassandra-Token: $_ASTRA_TOKEN'
    'https://$_ASTRA_URL/api/rest/v2/keyspaces/community/movies/Bee%20Movie/2007'

Unfortunately, the Swagger UI encodes the slash (/) as %2F so you'll need to manually override it when you code the URL in your app. In your case, the URL for a REST API call would look something like:

    /api/rest/v2/keyspaces/example/names/id/name/age

Cheers!

1 comment 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.

Hello Eric! Thanks for the example, and Apologies for not making myself clear.

The problem was the swagger UI was encoding my slash as %2F. so I was getting the mssing partition key Error!

Thanks for your answer! it solved my issue!

0 Likes 0 ·