title: Angular2 - Http POST request parameters
body: <p>I'm trying to make a POST request but i can't get it working:</p>
  
  <pre><code>testRequest() {
        var body = 'username=myusername?password=mypassword';
        var headers = new Headers();
        headers.append('Content-Type', 'application/x-www-form-urlencoded');
  
        this.http
          .post('/api',
            body, {
              headers: headers
            })
            .subscribe(data =&gt; {
                  alert('ok');
            }, error =&gt; {
                console.log(JSON.stringify(error.json()));
            });
  }
  </code></pre>
  
  <p>I basically want to replicate this http request (not ajax) like it was originated by a html form:</p>
  
  <p>URL: /api</p>
  
  <p>Params: username and password</p>