title: AWS Lambda send response to API Gateway
body: <p>I have a lambda function that generates some text. This is for a simple Twilio app</p>
  
  <pre><code>&lt;Say&gt;Welcome to your conference room!&lt;/Say&gt;
  &lt;Dial&gt;
     &lt;Conference beep="true"&gt;waitingRoom&lt;/Conference&gt;
  &lt;/Dial&gt;
  </code></pre>
  
  <p>When I make a POST request using postman it outputs exactly that. but I have two problems:</p>
  
  <ol>
  <li>The headers comes back at application/json, and I need it as text/xml.</li>
  <li>When I make the POST request from Twilio I get 502 Bad Gateway </li>
  </ol>
  
  <p>I know it has to do something with the incoming params mapping and also mapping the response from Lambda back to the API Gateway as text/xml. But I can;t figure out how to do this. </p>
  
  <p><a href="https://i.stack.imgur.com/x2yCH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x2yCH.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/8uADG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8uADG.png" alt="enter image description here"></a></p>