Unable to GET Key data using keyId - Tyk Gateway API

Hi.
I’m trying to retrieve the list of Keys generated and I’m able to do so using the cURL command:
curl --location --request GET ‘http://localhost:8080/tyk/keys’ --header ‘x-tyk-authorization: your_secret_defined_in_tyk.conf’.

I’m returned with a list of Keys:
{
“keys”: [
“0b32f3f109d15656”,
“54154fb538185c0a”,
“df8813a90f90e6fa”
]
}

Now, I’m trying to access the quotas and the rate limiting data setup for that particular key using the cURL command:
curl --location --request GET ‘http://localhost:8080/tyk/keys/0b32f3f109d15656’ --header ‘x-tyk-authorization: your_secret_defined_in_tyk.conf’.

Ideally, I’m supposed to be returned with the rate limiting and quotas set for that particular Key, but instead i get a 404(Not Found) Error. API Call Response:
{
“status”: “error”,
“message”: “Key not found”
}

One thing to note here is that when I’m using the GUI, to get the Key using the Key hash, it works perfectly, but when I’m trying to get it using REST API, it fails and returns 404.

Help would be really appreciated.

Thanks,
Prashanth (@selvamp)

Can I just check that you have hashed key listing enabled @selvamp ? Tyk Gateway v2.6

Yes @ahmet.
“enable_hashed_keys_listing”: true in tyk.conf file.

can you try to call that endpoint with query parameter hashed=true?

1 Like

Thanks @ahmet. This works!

Even though I set “enable_hashed_keys_listing” as TRUE in tyk.conf, explicitly mentioning hashed=true as a query param solves the problem.

Thanks and Cheers!
Prashanth (@selvamp)

Ok, if I might be wrong, but this may have been for backward compatibility reasons. We will have wanted to ensure that updating the configs wouldn’t break functionality for old keys or keys which were non-hashed.

Understood @ahmet.
Thanks for the reply, really appreciate it!

Regards,
Prashanth (@selvamp)