API Gateway boto3 API not working

0

Hi,

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 Answers
0

Hi!

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

AWS
ART
answered 9 months ago
0

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.

answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions