Deploying via API with javascript

Hi,

I’m trying to deploy a release using the npm module “request” but keep getting errors no matter how I post.

This is what I’m trying

var request = require('request');
var octopusServer = 'http://myOctopusServer';
request.post({
    headers: { 'X-Octopus-ApiKey': 'my-actual-apikey' },
    json: true,
    url: octopusServer + '/api/deployments',
    body: {
        ReleaseID: 'actualReleaseId',
        EnvironmentID: 'actualEnvironmentId'
    }
}, function(err, res){
    if(err) { throw err; }
    console.log(res);
})

I’ve tried settings json to false, stringifying the body object or using form/formData instead.

Any help appreciated!!

Thanks,
Tobias

Update
Ok, so I accidentally solved this by using the powershell deploy examples, posting to my own server and reverse engineering the signature with js/request.

Turns out that I only got it to work like this:

var deploy = {
    ReleaseID: 'xxx',
    EnvironmentID: 'yyy'
}
var formData = JSON.stringify(deploy, null, 4);  
request.post({
    headers: 'as above',
    json: true,
    form: formData,
    url: 'as above'
}, function(err, resp){ ... })

Made a pull request to octopackjs with new deploy command.