how to post data in node.js with content type ='application/x-www-form-urlencoded'
<p>I'm having a problem in posting data in node.js with <code>Content-type: 'application/x-www-form-urlencoded'</code></p>

<pre><code>var loginArgs = {
    data: 'username="xyzzzzz"&amp;"password="abc12345#"',

    //data: {
    //    'username': "xyzzzzz",
    //    'password': "abc12345#",
    //},

    headers: {
            'User-Agent': 'MYAPI',
            'Accept': 'application/json',
            'Content-Type':'application/x-www-form-urlencoded'      
    }   
};
</code></pre>

<p>And post request is:</p>

<pre><code>client.post("http:/url/rest/login", loginArgs, function(data, response){
console.log(loginArgs);

if (response.statusCode == 200) {
    console.log('succesfully logged in, session:', data.msg);
}
</code></pre>

<p>It always returns <strong>username/password</strong> incorrect.</p>

<p>In the rest api it is said that the request body should be:</p>

<pre><code>username='provide user name in url encoded
format'&amp;password= "provide password in url encoded format'
</code></pre>