有沒有在方法請求和集成請求中定義URL查詢字符串參數並將查詢字符串傳遞給HTTP代理的方法?如何在不通過AWS API網關預先定義的情況下傳遞URL查詢字符串參數
例如,在HTTPS的情況下:// {API ID} -api.us-east-1.amazonaws.com/test/user?start=1 &端= 10
查詢字符串 1 。開始 2.結束
如果我把方法請求和集成請求中的URL查詢字符串參數,然後我能夠得到兩個查詢字符串。但是,如果我不添加它們並在郵遞員中發出請求,那麼在後端,我沒有收到兩個查詢字符串。
我想在沒有在方法請求和集成請求中定義的情況下獲取查詢字符串。原因是如果有多個參數,我不想輸入所有參數。
有沒有辦法做到這一點?
我正在使用HTTP代理,這裏是我正在使用的模板映射。 (它實際上是方法請求傳遞下拉菜單)。
#set($allParams = $input.params())
{
"body-json" : "$input.json('$')",
"params" : {
#foreach($type in $allParams.keySet())
#set($params = $allParams.get($type))
"$type" : {
#foreach($paramName in $params.keySet())
"$paramName" : "$util.escapeJavaScript($params.get($paramName))"
#if($foreach.hasNext),#end
#end
}
#if($foreach.hasNext),#end
#end
},
"stage-variables" : {
#foreach($key in $stageVariables.keySet())
"$key" : "$util.escapeJavaScript($stageVariables.get($key))"
#if($foreach.hasNext),#end
#end
},
"context" : {
"account-id" : "$context.identity.accountId",
"api-id" : "$context.apiId",
"api-key" : "$context.identity.apiKey",
"authorizer-principal-id" : "$context.authorizer.principalId",
"caller" : "$context.identity.caller",
"cognito-authentication-provider" : "$context.identity.cognitoAuthenticationProvider",
"cognito-authentication-type" : "$context.identity.cognitoAuthenticationType",
"cognito-identity-id" : "$context.identity.cognitoIdentityId",
"cognito-identity-pool-id" : "$context.identity.cognitoIdentityPoolId",
"http-method" : "$context.httpMethod",
"stage" : "$context.stage",
"source-ip" : "$context.identity.sourceIp",
"user" : "$context.identity.user",
"user-agent" : "$context.identity.userAgent",
"user-arn" : "$context.identity.userArn",
"request-id" : "$context.requestId",
"resource-id" : "$context.resourceId",
"resource-path" : "$context.resourcePath"
}
}
如您所說在集成請求中添加了模板,但它不起作用。如果我沒有在URL查詢字符串參數中指定,我仍然不會收到查詢字符串。我沒有使用Lambda函數。 – jgranda2
你可以添加你的問題映射模板? –
我剛剛添加了映射模板,它實際上就是您所說的下拉菜單中的一個。在後端,我沒有得到請求中的任何查詢字符串。 – jgranda2