因此,我尝试通过 AWS cli 调用后端的 API,如文档中所示(https://docs.aws.amazon.com/cli/latest/reference/apigateway/test-invoke-method.html) :
# exalmple from the docs:
# aws apigateway test-invoke-method --rest-api-id 1234123412 --resource-id avl5sg8fw8 --http-method GET --path-with-query-string '/'
# my own call
aws apigateway test-invoke-method --rest-api-id ${restId} --resource-id ${resID} --http-method GET --path-with-query-string '/health'
但是,它失败了:
An error occurred (NotFoundException) when calling the TestInvokeMethod operation: Invalid Method identifier specified
错误消息令人困惑,让我觉得我不知道如何拼写
GET
。有什么问题可以帮忙吗?
版本
$ aws --version
aws-cli/2.15.15 Python/3.11.6 Darwin/23.3.0 exe/x86_64 prompt/off
好吧,我误解了
resource-id
的意思。我以为它标识了整个API,然后我传递一些路由“/route”来调用。
事实上,它标识了一个路由,而我调用的这个特定路由没有任何关联的 http 方法。所以我需要使用我想要调用的route的资源ID