我想运行以下命令:https://docs.aws.amazon.com/cli/latest/reference/apigateway/test-invoke-method.html
它需要这两个字段,无法找到任何文档,如果它们是:
aws apigateway test-invoke-method --rest-api-id 1234123412 --resource-id avl5sg8fw8 --http-method GET --path-with-query-string '/'我的API网关端点如下所示:
https://abc123.execute-api.us-east-1.amazonaws.com/MyStage/我只在那里看到了唯一的标识符,但是这个命令似乎需要两个I。我在哪里可以在API网关控制台中找到它们?
发布于 2018-09-21 17:48:13
您的rest id是端点URL中执行-api之前的标识符。
在您的示例URL中:
https://abc123.execute-api.us-east-1.amazonaws.com/MyStage/rest-api-id是abc123
可以使用get-resources调用和rest-api- ID使用CLI获得资源id:
> aws apigateway get-resources --rest-api-id abc123
{
"items": [
{
"id": "xxxx1",
"parentId": "xxxx0",
"pathPart": "foo",
"path": "/foo",
"resourceMethods": {
"GET": {}
}
},
{
"id": "xxxx0",
"path": "/"
}
]}items属性中的每个记录都是资源,它的id属性是您可以在测试调用方法中使用的资源ID,以及与资源关联的方法。
当您选择一个端点/资源时,两个值都可以在控制台的顶部看到:

发布于 2020-12-03 03:06:55
这里是bash脚本的一部分,您可以使用它,前提是安装了jq来解析json,并且只有一个API。它从items数组中获取第一个API ID,然后查找该资源ID,然后使用POST调用API:
API_ID=`aws apigateway get-rest-apis | jq -r ".items[0].id"`
RESOURCE_ID=`aws apigateway get-resources --rest-api-id $API_ID | jq -r ".items[].id"`
aws apigateway test-invoke-method --rest-api-id $API_ID --resource-id $RESOURCE_ID --http-method POSThttps://stackoverflow.com/questions/52446929
复制相似问题