title: Axios: Send variable in the body of a POST request and not params
body: <p>I am working on a project where i need to send authentication variables in the body of the request and not as parameters. I see that a POST request sends the second parameter as the body in the documentation but I am getting an error in the .NET service.</p>
  
  <pre><code>_response: "{"error":"invalid_clientId","error_description":"ClientId should be sent."}"
  </code></pre>
  
  <p>I was getting the same error in PHP when I wasn't send the params in the body but the values are all the same that I am using in this POST request so I know the params and values are correct.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>axios.post(`https://myawesomeapi.com`, 
  {username:this.state.email_address, password:this.state.password, grant_type:'password', client_id:'thisAppsClientID'}, 
  {headers: { 'content-type':'application/x-www-form-urlencoded', 'accept':'application/json' }}
  ).then( res =&gt; {
    let result = res.data;
    console.log(result);
  })
  .catch( (e) =&gt; {  console.log(e.response); });
  </code></pre>
  
  <p>When I console.log and inspect the error response I see this:</p>
  
  <pre><code>config:
     adapter: ƒ xhrAdapter(config)
     data: "{"username":"myusername","password":"mypassword!","grant_type":"password","client_id":"thisAppsClientID"}"
     headers: {Accept: "application/json, text/plain, */*", Content-Type: "application/x-www-form-urlencoded"}
  ...
  </code></pre>
  
  <p>Here is what I have in guzzle that is working if that helps:</p>
  
  <pre><code>    $this-&gt;client-&gt;request('post', 'https://myawesomeapi.com',
  ['form_params' =&gt; ['username' =&gt; $input['username'], 'password' =&gt; $input['password'], 'client_id'=&gt;'thisAppsClientID', 'grant_type'=&gt;'password']],
  ['headers' =&gt; ['accept' =&gt; 'application/json','Content-Type' =&gt; 'application/x-www-form-urlencoded']]);
  </code></pre>
  
  <p>Is the username, password, grant_type, and client_id being passed as the body? Did I mess up how to send the headers? Thanks and let me know!</p>