Reputation: 27
My API on API Gateway works when I test it in the console on AWS, but when I call the endpoint with the parameter it fails.
My test on AWS console:
Request: /extract?extension=txt
Status: 200
Latency: 725 ms
Response Body
(This is what I am trying to GET, the result of the text extraction and it works beautifully on the AWS console:)
"Joe\r\nJeff\r\n9902185124085\r\n0795121864\r\nRandom text\r\nwhite\r\nmarried\r\nawesome random text yeeeaaaa"
Response Headers
{"X-Amzn-Trace-Id":"Root=1-5fa83aab-62d2d49eb1a7ba6c13f39095;Sampled=0","Content-Type":"application/json"}
Logs
Sun Nov 08 18:36:27 UTC 2020 : Starting execution for request: 72b4287e-b002-4c27-b3d4-df9a68b6cc03
Sun Nov 08 18:36:27 UTC 2020 : HTTP Method: GET, Resource Path: /extract
Sun Nov 08 18:36:27 UTC 2020 : Method request path: {}
Sun Nov 08 18:36:27 UTC 2020 : Method request query string: {extension=txt}
Sun Nov 08 18:36:27 UTC 2020 : Method request headers: {}
Sun Nov 08 18:36:27 UTC 2020 : Method request body before transformations:
Sun Nov 08 18:36:27 UTC 2020 : Endpoint request URI: https://lambda.us-east-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-east-2:852812612033:function:myTextExtractor/invocations
Sun Nov 08 18:36:27 UTC 2020 : Endpoint request headers: {x-amzn-lambda-integration-tag=72b4287e-b002-4c27-b3d4-df9a68b6cc03, Authorization=************************************************************************************************************************************************************************************************************************************************************************************************************************c8d026, X-Amz-Date=20201108T183627Z, x-amzn-apigateway-api-id=2imdj98e48, X-Amz-Source-Arn=arn:aws:execute-api:us-east-2:852812612033:2imdj98e48/test-invoke-stage/GET/extract, Accept=application/json, User-Agent=AmazonAPIGateway_2imdj98e48, X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOL//////////wEaCXVzLWVhc3QtMiJGMEQCIGuYc6UZMKIGJfSbNs2ih4VyCmJvaojaLMhu+dcO8zQmAiArfOWhHu82I0ZIbmUCVD52DKReI9AGnZRA+CEO8r/1oCq0AwhMEAEaDDcxODc3MDQ1MzE5NSIMl/FCNpzw7OVWN1htKpEDpUhy7gEYYkQ+hqhKFHzyAWZNPbQw2cY1auhp1LpzvjpkJprpqC8vjviYCwwQRPsDZ7ltr/I+zb2EVOOD3hgw2Ey9esxgnPFOmkHdAoA7jYAtTTTm2ty4+lRqGxpHD5UOkv5tbLTsr4ChhLMzeM3oE [TRUNCATED]
Sun Nov 08 18:36:27 UTC 2020 : Endpoint request body after transformations: {
"fileExt": "txt"
}
Sun Nov 08 18:36:27 UTC 2020 : Sending request to https://lambda.us-east-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-east-2:852812612033:function:myTextExtractor/invocations
Sun Nov 08 18:36:27 UTC 2020 : Received response. Status: 200, Integration latency: 721 ms
Sun Nov 08 18:36:27 UTC 2020 : Endpoint response headers: {Date=Sun, 08 Nov 2020 18:36:27 GMT, Content-Type=application/json, Content-Length=111, Connection=keep-alive, x-amzn-RequestId=3d36218d-db9f-4f8c-bdee-00a7958c24bd, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=1-5fa83aab-62d2d49eb1a7ba6c13f39095;sampled=0}
Sun Nov 08 18:36:27 UTC 2020 : Endpoint response body before transformations: "Joe\r\nJeff\r\n9902185124085\r\n0795121864\r\nRandom text\r\nwhite\r\nmarried\r\nawesome random text yeeeaaaa"
Sun Nov 08 18:36:27 UTC 2020 : Method response body after transformations: "Joe\r\nJeff\r\n9902185124085\r\n0795121864\r\nRandom text\r\nwhite\r\nmarried\r\nawesome random text yeeeaaaa"
Sun Nov 08 18:36:27 UTC 2020 : Method response headers: {X-Amzn-Trace-Id=Root=1-5fa83aab-62d2d49eb1a7ba6c13f39095;Sampled=0, Content-Type=application/json}
Sun Nov 08 18:36:27 UTC 2020 : Successfully completed execution
Sun Nov 08 18:36:27 UTC 2020 : Method completed with status: 200
But I get this error on Postman:
<AccessDeniedException>
<Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>
This is my endpoint URL (API_CODE and REGION is obviously substituted with my own):
https://API_CODE.execute-api.REGION.amazonaws.com/1/extract?extension=txt
And I tested that it works, because if I call it without the parameter, then it says it requires the extension parameter.
The API get action invokes a lambda function.
NO Auth or tokens are required, as per settings in the API.
I followed the AWS calculation API tutorial, so I would believe that all my URL parameters, and integration settings is alright, and since it works on the console?
Thanks in advance!
Upvotes: 1
Views: 1741
Reputation: 27
I redeployed the API. Then got a "Forbidden message". Then called it without the parameter. Also forbidden. Then I tried again with the parameter, yet again forbidden. I redeployed the API a second time, changing nothing. And now it works. Nice.
Upvotes: 1