I landed here when I was trying to do a similar thing. For a application/x-www-form-urlencoded content type, you could try to use this for the body:
var body = 'username' =myusername & 'password'=mypassword;
with what you tried doing the value assigned to body will be a string.