title: payload is not valid JSON
body: <p>I'm using <code>curl</code> to send JSON to an API endpoint. However, somewhere in the bash chain it is getting messed up.</p>
  
  <p>Is there something special to know about encoding with <code>curl</code>?</p>
  
  <p>If I construct the payload like this:</p>
  
  <pre><code> PAYLOAD='payload={"channel": "github", "username": "webhookbot", "icon_emoji": ":ghost:", "text": "'
   PAYLOAD+=$1
   PAYLOAD+=' " }'
  
   echo $PAYLOAD
   curl -X POST --data-urlencode "$PAYLOAD" $SLACKPOSTURL
   echo "sent"
  </code></pre>
  
  <p>I'll get back an error</p>
  
  <blockquote>
    <p>Payload was not valid JSONsent</p>
  </blockquote>
  
  <p>however if i just hardwire to assign a variable with the output</p>
  
  <pre><code>PAYLOAD='payload={"channel": "github", "username": "webhookbot", "icon_emoji": ":ghost:", "text": "LAST_COMMIT Merge pull request #558 from dcsan/boteditor Boteditor " }'
  </code></pre>
  
  <p>then it will go through fine.</p>
  
  <p>Is there something that a simple assignment is doing differently vs. concatenating strings? In the console the output looks identical.</p>
  
  <p>FWIW some messages go through but content like this:</p>
  
  <blockquote>
    <p>LAST_COMMIT Merge pull request #558 from dcsan/boteditor Boteditor </p>
  </blockquote>
  
  <p>will only go through if hardcoded in. so its not the other end afaican see, its something to do with the way messages are built.</p>