title: Getting 400 Bad Request on axios post call
body: <p>I'm using a url shortner API to test connecting to a API and I keep getting a 400 BadRequest.  I've read through a dozen posts here and tried all suggestions and still nothing will work.  I don't know what I'm doing wrong.</p>
  <p>Function</p>
  <pre><code>var axios = require('axios');
  </code></pre>
  <p>module.exports = function (callback, data) {</p>
  <pre><code>let url = 'https://cleanuri.com/api/v1/shorten';
  
  let axiosConfig = {
      &quot;headers&quot;: {
          'Content-Type': 'application/json;charset=UTF-8'
      }
  };
    
  
  let longUrl = { &quot;url&quot; : data };
  
  axios(url, {
      method: &quot;post&quot;,
      params: {
          &quot;url&quot; : data
      },
      headers: {
          &quot;Accept&quot;: &quot;application/json&quot;,
          &quot;Content-Type&quot;: &quot;application/json&quot;
      }
  })
  .then(function (response) {
      callback(null, response.data);
  }).catch(function (err) {
      console.log(&quot;error: &quot; + err.response);
      callback(err, null);
  });
  </code></pre>
  <hr />
  <p>I've also tried this and got same error</p>
  <pre><code>    axios.post(url, JSON.stringify(longUrl), axiosConfig)
  .then(function (response) {
      callback(null, response.data);
  }).catch(function (err) {
      console.log(&quot;error: &quot; + err.response);
      callback(err, null);
  });
  </code></pre>