Execution failed due to configuration error: Illegal character in path at index 46: http://petstore-demo-endpoint.execute-api.com/{proxy}?type=fish
Logs :
Execution log for request 965a6cd1-1f68-4b33-8bab-3741e40b0028
Fri Mar 20 08:19:39 UTC 2020 : Starting execution for request: 965a6cd1-1f68-4b33-8bab-3741e40b0028
Fri Mar 20 08:19:39 UTC 2020 : HTTP Method: GET, Resource Path: /test/petstore/pets
Fri Mar 20 08:19:39 UTC 2020 : Method request path: {proxy=petstore/pets}
Fri Mar 20 08:19:39 UTC 2020 : Method request query string: {type=fish}
Fri Mar 20 08:19:39 UTC 2020 : Method request headers: {}
Fri Mar 20 08:19:39 UTC 2020 : Method request body before transformations:
Fri Mar 20 08:19:39 UTC 2020 : Endpoint request URI: http://petstore-demo-endpoint.execute-api.com/{proxy}?type=fish
Fri Mar 20 08:19:39 UTC 2020 : Endpoint request headers: {x-amzn-apigateway-api-id=ssg89ys6y6, User-Agent=AmazonAPIGateway_ssg89ys6y6}
Fri Mar 20 08:19:39 UTC 2020 : Endpoint request body after transformations:
Fri Mar 20 08:19:39 UTC 2020 : Sending request to http://petstore-demo-endpoint.execute-api.com/{proxy}?type=fish
Fri Mar 20 08:19:39 UTC 2020 : Execution failed due to configuration error: Illegal character in path at index 46: http://petstore-demo-endpoint.execute-api.com/{proxy}?type=fish
Fri Mar 20 08:19:39 UTC 2020 : Method completed with status: 500
Adding this here for others who face the issue
https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-proxy-path-character-error/
Related
I try to use DYnamoDB directly from the API Gateway.
Before I successfully used GET method with Lambda. My lambda was used only for selection from the DynamoDB, so I decided to implement this simple query directly, so my steps:
I created {id} source and the GET method:
(need to note - the POST method works well via a lambda)
Updated the integration request:
updated Trust relationships for the role:
also Role has permissions for the GetItem:
after I updated the Mapped Templates:
{
"TableName": "Link",
"Key":
"id": {
"S": '$input.params("id")'
}
}
}
So, after method testing, I receive the following errors:
request: "S": '$input.params("id")'
error: {"__type":"com.amazon.coral.service#SerializationException"}
Additional info from the response:
Endpoint request body after transformations: {
"TableName": "Link",
"Key":
"id": {
"S": "3MEJh"
}
}
}
database cortage:
Full logs:
Execution log for request -30fa-4e7a-8524-ba0dde7375dd
Sun Oct 02 18:57:39 UTC 2022 : Starting execution for request: 1cc6e9fe-30fba0dde7375dd
Sun Oct 02 18:57:39 UTC 2022 : HTTP Method: GET, Resource Path: /3MEJh
Sun Oct 02 18:57:39 UTC 2022 : Method request path: {id=3MEJh}
Sun Oct 02 18:57:39 UTC 2022 : Method request query string: {}
Sun Oct 02 18:57:39 UTC 2022 : Method request headers: {}
Sun Oct 02 18:57:39 UTC 2022 : Method request body before transformations:
Sun Oct 02 18:57:39 UTC 2022 : Endpoint request URI: https://dynamodb.us-east-1.amazonaws.com/?Action=GetItem
Sun Oct 02 18:57:39 UTC 2022 : Endpoint request headers: {Authorization=, X-Amz-Date=20221002T185739Z, x-amzn-apigateway-api-id=, Accept=application/json, User-Agent=AmazonAPIGateway_, X-Amz-Security-Token= [TRUNCATED]
Sun Oct 02 18:57:39 UTC 2022 : Endpoint request body after transformations: {
"TableName": "Link",
"Key":
"id": {
"S": "3MEJh"
}
}
}
Sun Oct 02 18:57:39 UTC 2022 : Sending request to https://dynamodb.us-east-1.amazonaws.com/?Action=GetItem
Sun Oct 02 18:57:39 UTC 2022 : Received response. Status: 400, Integration latency: 6 ms
Sun Oct 02 18:57:39 UTC 2022 : Endpoint response headers: {Server=Server, Date=Sun, 02 Oct 2022 18:57:39 GMT, Content-Type=application/x-amz-json-1.0, Content-Length=60, Connection=keep-alive, x-amzn-RequestId=I669H6IF6GJD7NVV4KQNSO5AEMVJF66Q9ASUAAJG, x-amz-crc32=34863019}
Sun Oct 02 18:57:39 UTC 2022 : Endpoint response body before transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Sun Oct 02 18:57:39 UTC 2022 : Method response body after transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Sun Oct 02 18:57:39 UTC 2022 : Method response headers: {X-Amzn-Trace-Id=Root=339df23-575ea99d20ce6fb213b97a7b, Content-Type=application/json}
Sun Oct 02 18:57:39 UTC 2022 : Successfully completed execution
Sun Oct 02 18:57:39 UTC 2022 : Method completed with status: 200
I need to say - I had the same result when I broke my JSON request...so it seems the problem is another point.
So, what did I do wrong?
I have an API Gateway which routes requests to SQS, API Gateway has a the needed permission to send messages to SQS (Created IAM role), when I send test data, I'll get the response below with UnknownOperationException.
SQS is also empty with no messages available.
Tue Nov 09 13:46:11 UTC 2021 : Sending request to https://sqs.ca-central-1.amazonaws.com/XXXXXXXX/XXXX
Tue Nov 09 13:46:11 UTC 2021 : Received response. Status: 404, Integration latency: 2 ms
Tue Nov 09 13:46:11 UTC 2021 : Endpoint response headers: {x-amzn-RequestId=e63b5577-9866-569d-85d8-0f73e5851cf0, Date=Tue, 09 Nov 2021 13:46:11 GMT, X-Amzn-Trace-Id=Root=1-618a7ba3-dd93ee11df45d437f9c98705, Content-Type=null, Content-Length=29}
Tue Nov 09 13:46:11 UTC 2021 : Endpoint response body before transformations: <UnknownOperationException/>
Tue Nov 09 13:46:11 UTC 2021 : Method response body after transformations: <UnknownOperationException/>
Any ideas?
To fix that issue you have to add the Content-Type:'application/x-www-form-urlencoded' header to the integration request:
integration request headers
I'm using API Gateway's AWS Service integration type to add logs to the Cloudwatch Logs service using the PutLogEvents action, as described here: https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
I've successfully setup a similar type of method to add items into a DynamoDB table using the PutItem action and that worked just fine, so I'm not sure what I'm missing with this one.
I've double checked for typos and problems with my template. Have successfully used PutLogEvents using the CLI tools, so the setup seems all OK.
Here's some screenshots of my setup from the AWS dash:
Here's the mapping template I'm using:
{
"logGroupName": "FromAPI",
"logStreamName": "$input.path('$.streamName')",
"logEvents": [
{
"timestamp": $input.path('$.ts'),
"message": "$input.path('$.message')"
}
]
}
The response I get back has a 200 status code, but the following response body:
{
"Output": {
"__type": "com.amazon.coral.service#UnknownOperationException",
"message": null
},
"Version": "1.0"
}
Here's a redacted (xxx) execution log:
Execution log for request xxx
Fri Apr 19 02:28:58 UTC 2019 : Starting execution for request: xxx
Fri Apr 19 02:28:58 UTC 2019 : HTTP Method: POST, Resource Path: /log
Fri Apr 19 02:28:58 UTC 2019 : Method request path: {}
Fri Apr 19 02:28:58 UTC 2019 : Method request query string: {}
Fri Apr 19 02:28:58 UTC 2019 : Method request headers: {}
Fri Apr 19 02:28:58 UTC 2019 : Method request body before transformations: {
"streamName": "12345",
"ts": 1555641510000,
"message": "help!"
}
Fri Apr 19 02:28:58 UTC 2019 : Endpoint request URI: https://logs.xxx.amazonaws.com/?Action=PutLogEvents
Fri Apr 19 02:28:58 UTC 2019 : Endpoint request headers: {Authorization=xxx, X-Amz-Date=20190419T022858Z, x-amzn-apigateway-api-id=xxx, Accept=application/json, User-Agent=AmazonAPIGateway_xxx, X-Amz-Security-Token=xxx [TRUNCATED]
Fri Apr 19 02:28:58 UTC 2019 : Endpoint request body after transformations: {
"logGroupName": "FromAPI",
"logStreamName": "12345",
"logEvents": [
{
"timestamp": 1555641510000,
"message": "help!"
}
]
}
Fri Apr 19 02:28:58 UTC 2019 : Sending request to https://logs.xxx.amazonaws.com/?Action=PutLogEvents
Fri Apr 19 02:28:58 UTC 2019 : Received response. Status: 200, Integration latency: 38 ms
Fri Apr 19 02:28:58 UTC 2019 : Endpoint response headers: {x-amzn-RequestId=xxx, Content-Type=application/json, Content-Length=105, Date=Fri, 19 Apr 2019 02:28:58 GMT}
Fri Apr 19 02:28:58 UTC 2019 : Endpoint response body before transformations: {"Output":{"__type":"com.amazon.coral.service#UnknownOperationException","message":null},"Version":"1.0"}
Fri Apr 19 02:28:58 UTC 2019 : Method response body after transformations: {"Output":{"__type":"com.amazon.coral.service#UnknownOperationException","message":null},"Version":"1.0"}
Fri Apr 19 02:28:58 UTC 2019 : Method response headers: {X-Amzn-Trace-Id=Root=xxx, Content-Type=application/json}
Fri Apr 19 02:28:58 UTC 2019 : Successfully completed execution
Fri Apr 19 02:28:58 UTC 2019 : Method completed with status: 200
Nothing gets logged into my Cloudwatch Logs stream - the API Gateway integration request response body contains an UnknownOperationException error.
My best guess is that this request is not mapping to the PutLogEvents action for some reason. Strange that the status code is 200 in this situation.
I'm guessing it's just some typo - or an additional header that I need to send through? Any ideas?
It should work if you add the following lines at the top of your Mapping Template:
#set($context.requestOverride.header['X-Amz-Target'] = "Logs_20140328.PutLogEvents")
#set($context.requestOverride.header['Content-Type'] = "application/x-amz-json-1.1")
This is very tricky and not well documented. You can find those headers in the sample request for PutLogEvents.
I'm making a GetItem call to a DynamoDB via API Gateway integration. My request mapping is:
{
"TableName": "connected-content-dynamodb",
"Key": {
{ "id" :
{"S" : "$input.params('entity-id')"}
}
}
}
Response template is:
{ "payload" : "$input.json('$')"}
Logs that I get:
Thu Nov 22 10:31:51 UTC 2018 : Endpoint request body after transformations: {
"TableName": "connected-content-dynamodb",
"Key": {
{ "id" :
{"S" : "123"}
}
}
}
Thu Nov 22 10:31:51 UTC 2018 : Sending request to https://dynamodb.eu-west-1.amazonaws.com/?Action=GetItem
Thu Nov 22 10:31:51 UTC 2018 : Method response body after transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Thu Nov 22 10:31:51 UTC 2018 : Method response headers: {X-Amzn-Trace-Id=Root=1-5bf68597-8d22f7ca52c6af2aded083e0, Content-Type=application/json}
Thu Nov 22 10:31:51 UTC 2018 : Successfully completed execution
Thu Nov 22 10:31:51 UTC 2018 : Method completed with status: 404
Any ideas whats wrong? Or how to debug it?
As per here, I believe that setting a header of X-Amz-Invocation-Type: Event should set my Lambda invocation to be asynchronous.
However, by putting a import time;time.sleep(5000) at the beginning of my Lambda function, and sending requests to my API Gateway, I observe that:
$ aws apigateway get-integration --rest-api-id <api-id> \
--resource-id <resource-id> \
--http-method POST | jq -r '.requestParameters'
{
"integration.request.header.X-Amz-Invocation-Type": "'Event'"
}
$ aws apigateway get-integration --rest-api-id <api-id> \
--resource-id <resource-id> \
--http-method POST | jq -r '.uri'
arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:<account-id>:function:[...]Lambda-4HOA0ZSFAYCI/invocations
$ curl https://<api-id>.execute-api.us-east-1.amazonaws.com/LATEST/<path> -d '{}'
{"message": "Endpoint request timed out"}
[here I removed the sleep from my lambda function and made it return immediately]
$ curl https://<api-id>.execute-api.us-east-1.amazonaws.com/LATEST/<path> -d '{}'
{"body": "Request OK", "headers": {"Content-Type": "application/json"}, "statusCode": 200}
Assuming that the documentation is accurate, my best guess is that I've misconfigured the Integration somehow - perhaps the "'Event'" is incorrect and it should be "Event"? I'm pretty sure the single-quotes are required, however, to demarcate a static value (as opposed to value parsed from the request). In particular, I suspect that my responseParameters are not right:
$ aws apigateway get-integration --rest-api-id <api-id> \
--resource-id dzv1zj \
--http-method POST | jq -r '.integrationResponses'
{
"200": {
"responseTemplates": {
"application/json": null
},
"statusCode": "200"
}
}
Should null there be some VTL that staticly returns a 200 OK?
As for alternatives: I see that invoke-async is deprecated. I'd really rather not go to the overhead of going API Gateway -> SNS -> Lambda.
EDIT: Here are the logs from calling the API via the "Test" option on the console:
Execution log for request test-request
Wed Mar 07 17:24:57 UTC 2018 : Starting execution for request: test-invoke-request
Wed Mar 07 17:24:57 UTC 2018 : HTTP Method: POST, Resource Path: /<path>
Wed Mar 07 17:24:57 UTC 2018 : Method request path: {}
Wed Mar 07 17:24:57 UTC 2018 : Method request query string: {}
Wed Mar 07 17:24:57 UTC 2018 : Method request headers: {}
Wed Mar 07 17:24:57 UTC 2018 : Method request body before transformations: {"abc":"def"}
Wed Mar 07 17:24:57 UTC 2018 : Endpoint request URI: https://lambda.us-east-1.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-east-1:<account-id>:function:[...]Lambda-4HOA0ZSFAYCI/invocations
Wed Mar 07 17:24:57 UTC 2018 : Endpoint request headers: {X-Amz-Date=20180307T172457Z, x-amzn-apigateway-api-id=<api-id>, Accept=application/json, User-Agent=AmazonAPIGateway_<api-id>, Host=lambda.us-east-1.amazonaws.com, X-Amz-Content-Sha256=2c3fbda5f48b04e39d3a87f89e5bd00b48b6e5e3c4a093de65de0a87b8cc8b3b, X-Amzn-Trace-Id=Root=1-5aa02069-8670eb5d98dbc4ade9df03d8, x-amzn-lambda-integration-tag=test-request, Authorization=**********************************************************************************************************************************************************************************************************************************************************************************************************************************************bfe3de, X-Amz-Source-Arn=arn:aws:execute-api:us-east-1:<account-id>:<api-id>/null/POST/<path>, X-Amz-Invocation-Type=Event, X-Amz-Security-Token=[REDACTED] [TRUNCATED]
Wed Mar 07 17:24:57 UTC 2018 : Endpoint request body after transformations: {"abc":"def"}
Wed Mar 07 17:24:57 UTC 2018 : Sending request to https://lambda.us-east-1.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-east-1:<account-id>:function:[...]Lambda-4HOA0ZSFAYCI/invocations
Wed Mar 07 17:24:57 UTC 2018 : Received response. Integration latency: 43 ms
Wed Mar 07 17:24:57 UTC 2018 : Endpoint response body before transformations:
Wed Mar 07 17:24:57 UTC 2018 : Endpoint response headers: {x-amzn-Remapped-Content-Length=0, Connection=keep-alive, x-amzn-RequestId=75501cbf-222c-11e8-a1fc-2b19f19a9429, Content-Length=0, Date=Wed, 07 Mar 2018 17:24:57 GMT, X-Amzn-Trace-Id=root=1-5aa02069-8670eb5d98dbc4ade9df03d8;sampled=0}
Wed Mar 07 17:24:57 UTC 2018 : Method response body after transformations:
Wed Mar 07 17:24:57 UTC 2018 : Method response headers: {X-Amzn-Trace-Id=sampled=0;root=1-5aa02069-8670eb5d98dbc4ade9df03d8, Content-Type=application/json}
Wed Mar 07 17:24:57 UTC 2018 : Successfully completed execution
Wed Mar 07 17:24:57 UTC 2018 : Method completed with status: 200
Now I feel stupid - I needed to deploy my API. That seems like the API Gateway equivalent of "Have you tried turning it off and turning it on again?" :)
I found scubbo's answer but it didn't enlighten me until much later, so I post the same, but with a screenshot for any future lost soul