json - api gateway CORS setup -
i'm attempting setup aws cors command line using aws-cli in deployment script. have created post resource following perl shell command. i'm attempting set integration-response '*' enabling cores do.
aws apigateway put-method-response \\ --region "$region" \\ --rest-api-id "$api_id" \\ --resource-id "$resource_id" \\ --http-method "post" \\ --status-code 200 \\ --response-models '{"application/json":"empty"}' \\ --response-parameters '{"method.response.header.access-control-allow-origin":true}'
when run following command set integration value.
aws apigateway put-integration-response \\ --region "$region" \\ --rest-api-id "$api_id" \\ --resource-id "$resource_id" \\ --http-method "$method" \\ --status-code 200 \\ --response-template '{"application/json":"empty"}' \\ --response-parameters \\ '{"method.response.header.access-control-allow-origin": "'*'"}'
i following error.
a client error (badrequestexception) occurred when calling putintegrationresponse operation: invalid mapping expression specified: validation result: warnings : [], errors : [invalid mapping expression specified: *]
can tell me error referring or better way go api gateway deployment script.
the api gateway management console has nice 'enable cors' feature, may have seen. far replicating using cli, i'd suggest using console feature, observing configuration afterwards, , using same parameters in cli requests.
the error you're seeing must caused incorrect escaping of single quotes value '*' because character * not valid. point out potential problem, input --response-templates '{"application/json":"empty"}' valid not interpreted same --response-models in method-response object. value set response body "empty" api calls use integration-response. passthrough, don't set value of --response-templates
Comments
Post a Comment