How do I conditionally set field in AWS API Gateway integration template?
<p>I have an API Gateway to Lambda integration. In integration template I would like to check one of the input params and depending on it's value, I would like to set field in event that gets passed to Lambda. For that I wrote integration template but it always seems to go in else case even when I pass 'ext-prod-live' as environment in POST request.
So my event['stage_variables']['solr_url'] is always $stageVariables.solr_url. I think that I am not accessing POST body correctly and getting "" back from $input.params('environment').</p>

<p><strong>Template</strong></p>

<pre><code>#set($inputJson = $input.json('$')) { "request" : $inputJson, "Authorization" : "$input.params().header.get('Authorization')",
#if ( $input.params('environment') == "ext-prod-live" ) "stage_variables" : {"solr_url" : "$stageVariables.live_solr_url"}
#else "stage_variables" : {"solr_url" : "$stageVariables.solr_url"}
#end }
</code></pre>

<p><strong>Request body</strong></p>

<pre><code>{"environment": "ext-prod-sim", "min_ts": 0,
                "execType": 14}
</code></pre>

<p>Any help is much appreciated.</p>