API Gateway boto3 API not working



When I am trying to view the API gateway method with get_resource() and get_method() it's showing an error: An error occurred (NotFoundException) when calling the GetMethod operation: Invalid Method identifier specified

Output is: {'ResponseMetadata': {'RequestId': 'ff9399db-6ea3-4c0a-a2b8-218aa951be1f', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Wed, 30 Aug 2023 13:23:55 GMT', 'content-type': 'application/json', 'content-length': '31', 'connection': 'keep-alive', 'x-amzn-requestid': 'ff9399db-6ea3-4c0a-a2b8-218aa951be1f', 'x-amz-apigw-id': 'Kedk0LqmIAMEb6g='}, 'RetryAttempts': 0}, 'id': 'hwfdny4fbk', 'path': '/'}

When I run the same cli command: aws apigateway get-resource --rest-api-id gyox2qyani --resource-id bmw2m5 --profile test-lab --region us-east-1

The output is showing:

    "id": "bmw2m5",
    "parentId": "hwfdny4fbk",
    "pathPart": "testresource",
    "path": "/testresource",
    "resourceMethods": {
        "POST": {}

Please check the API else, kindly provide a solution.

2개 답변


I believe the code that you are running - as per the screen capture:

aws apigateway get-resource --rest-api-id gyox2qyani --resource-id bmw2m5 --profile test-lab --region us-east-1

On further investigating, I found a link: AWS CLI Command Reference for get-resource

I was able to look into the Global Options, and was curious about the particular option as chosen by you, namely:

--profile test-lab

I find that to be of interest, as the syntax points to:

--profile (string) Use a specific profile from your credential file. - thereby pointing to a user profile if you will. So my question to you is - does test-lab form an entry in your credentials file? If not, can you please amend the query and run it again?

I hope this helps.

If you find that I have answered your query, please mark it with an Accepted Answer

답변함 10달 전

Can you post your get_method() syntax here? I suspect you are missing the HTTP Method (get/post/put etc) from the request, or haven't specified one recognized by your api.

답변함 10달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인