title: Mattermost incoming webhooks error, "Unable to parse incoming data"
body: <p>Judging by the amount of information out there this does not seem like a common way to execute mattermost webhooks. We have a mattermost installation, we have an older web application used to lookup inventory, we would like to be able to via webhook send a message to a team containing some information relating to a part search request.</p>
  
  <p>I almost thought I could get away with making an ajax post request to the webhook URL with the "payload" set as a param, but this returns 400 "Unable To Parse Incoming Data", I thought for whatever reason the ajax request was the issue so I created a PHP script to do the curl request, this is what I have;</p>
  
  <pre><code>&lt;?php
  
  $payload = json_encode($_REQUEST['payload']);
  
  $ch = curl_init('http://dev2:8065/hooks/6isjcohwyibsf8kp5g9p6bcgoa');
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS, "$payload");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  
  $result = curl_exec($ch);
  
  echo $result;
  </code></pre>
  
  <p>Any suggestion at this point would be worthwhile. This either can't be done for whatever reason or it's so trivial I'm over thinking it.</p>
  
  <hr>
  
  <p><strong>payload sample,</strong></p>
  
  <p>The payload being sent:</p>
  
  <pre><code>'payload={"text": "| Component  | Tests Run   | Tests Failed |
  |:-----------|:------------|:-----------------------------------------------|
  | Server     | 948         | :white_check_mark: 0|
  | Web Client | 123         | :warning: [2 (see details)(http://linktologs) |
  | iOS Client | 78          | :warning: [3 (see details)](http://linktologs) |"}'
  </code></pre>
  
  <p>This entire string is being sent in the request.</p>
  
  <hr>
  
  <p><strong>Works with this,</strong></p>
  
  <p>If I break up the payload inside the php like so:</p>
  
  <pre><code>$body = '| Component  | Tests Run   | Tests Failed |\n|:-----------|:------------|:---------------------------------------------|\n| Server     | 948         | :white_check_mark: 0                         |\n| Web Client | 123         | :warning: [2 (see details)](http://linktologs) |\n| iOS Client | 78          | :warning: [3 (see details)](http://linktologs) |\n';
  
  $payload = 'payload={"text": "';
  $payload .= $body;
  $payload .= '"}';
  </code></pre>
  
  <p>It works as expected.</p>