I want list list APIs available on my AWS API Gateway instance using REST API. I tried:
- v2 API :: https://apigateway.eu-central-1.amazonaws.com/v2/apis
- v1 API :: https://apigateway.eu-central-1.amazonaws.com/restapis
I am using the same auth credentials for both calls.
Both respond with 200 OK.
- v1 returns proper data with my APIs
- v2 returns an empty response ( {"items": []} )
- AWS-CLI v2 command
aws apigateway get-rest-apisreturns proper data
Any idea why v2 REST API returns empty response?
v1 api gateways and v2 api gateways are distinct resources in AWS. In v1 there are only
RESTAPI Gateways and in v2 there are two types:HTTPandWebSocketgateways. They can coexist but they are incompatible with each-other and have very different feature sets.For an overview of the differences, see the comparison between the types of API gateway here: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html
But to more specifically answer your question, the response from https://apigateway.eu-central-1.amazonaws.com/v2/apis is empty because you do not have any v2 "HTTP" apis and "REST" apis do not exist in v2.
The reason you see them in the v2 cli is because the v2 cli tools support both through separate sub-commands. It's not the version of the cli that matters so much as which sub-command you use:
apigatewayv2apigateway.So using the v2 AWS-CLI with the
apigatewaysub-command is still accessing v1apigatewayresources.You need to use
aws apigatewayv2 get-apisfor the equivalent functionality when working with the "HTTP" API gateway resources.