title: AWS Api Gateway connect to SQS with message attributes
body: <p>I have connected an Api Gateway method to push onto a SQS Queue by following this tutorial.</p>
  
  <p><a href="https://dzone.com/articles/creating-aws-service-proxy-for-amazon-sqs" rel="nofollow noreferrer">https://dzone.com/articles/creating-aws-service-proxy-for-amazon-sqs</a></p>
  
  <p>This all works fine but I would like to add some Message Attributes to my messages using some path parameters but I can not get it to work.</p>
  
  <p>This is the current Mapping Template from the tutorial.</p>
  
  <pre><code>Action=SendMessage&amp;MessageBody=$util.urlEncode($util.escapeJavaScript($input.json('$')))
  </code></pre>
  
  <p>I've tried to keep the 'application/x-www-form-urlencoded' format and add the MessageAttributes to this by changing it to (using a static value for now)</p>
  
  <pre><code>    Action=SendMessage&amp;MessageBody=$util.urlEncode($util.escapeJavaScript($input.json('$')))
  &amp;MessageAttribute[0][Name]=foo&amp;MessageAttribute[0][Type]=String&amp;MessageAttribute[0][Value]=bar
  </code></pre>
  
  <p>but I get this error back</p>
  
  <pre><code>{
    "Error": {
      "Code": "MalformedQueryString",
      "Message": "Keys may not contain [",
      "Type": "Sender"
    },
    "RequestId": "ea121e6e-ca37-5d14-b92b-4a2c6fedf403"
  }
  </code></pre>
  
  <p>How should I encode an array of MessageAttribues without using '['</p>