英文:
aws step function converting special characters to UTF-8 in URL (not able to pass correct URL with query parameter to API gateway)
问题
以下是翻译好的内容:
我正在使用步函数中的api-gateway调用任务,但无法在路径中使用查询参数。
以下是我的步函数定义:
{
"Type": "Task",
"Resource": "arn:aws:states:::apigateway:invoke",
"Parameters": {
"ApiEndpoint": "endpoint",
"AuthType": "IAM_ROLE",
"Headers": {
"Content-Type": [
"application/json"
]
},
"Method": "GET",
"Path": "path?a=1",
"RequestBody.$": "$"
},
"End": true
}
当我在查询参数中使用a=1时,它会将其转换为path%3F%7B%7D
格式并引发错误。
我也了解apigateway调用任务中的查询参数,但问题是我有类似a=1的输入,如果我将其传递给查询参数,它也会失败,因为查询参数期望类似这样的内容:
"QueryParameters": {
"a": [
"1"
]
}
有没有办法在步函数中解决这个问题?
英文:
I am using api-gateway invoke task in step-function but not able to use query parameters in PATH
here is my step function defination
{
"Type": "Task",
"Resource": "arn:aws:states:::apigateway:invoke",
"Parameters": {
"ApiEndpoint": "endpoint",
"AuthType": "IAM_ROLE",
"Headers": {
"Content-Type": [
"application/json"
]
},
"Method": "GET",
"Path": "path?a=1",
"RequestBody.$": "$"
},
"End": true
}
when I use a=1 in query parameter it converts it to path%3F%7B%7D
like format and give error.
I also know about queryparameter in apigateway invoke task but the problem is I have input like a=1 if I pass this to query parameter it will also fail. as query paramter expect something like this
"QueryParameters": {
"a": [
"1"
]
}
Any idea how to solve this problem within step function?
答案1
得分: 0
我已经通过从API网关分别传递查询参数作为键和值来解决了这个问题。
{
"key": "a",
"value": "1"
}
然后在状态机中使用内置函数来处理查询参数,如下所示:
"QueryParameters.$": "States.StringToJson(States.Format(' { \"{}\":[{}] }', $.key , $.value))"
英文:
I have solved problem by passing query parameter from api-gateway separately as key and value
{
"key": "a",
"value": "1"
}
then used Intrinsic functions in state machine to handle in QueryParameter like this:
"QueryParameters.$": "States.StringToJson(States.Format(' \\{ \"{}\":[\"{}\"] \\}', $.key , $.value))"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论