HTTP Client to Post Projection (in javascript)

I’m close yet so far away. I’m getting a response status code of 201 with the following code, but I’m seeing some kruft when I open the project in EventStore.
Please advise.


request({

method: 'POST',

qs: {

name: projection.name,

emit: 'yes',

checkpoints: 'yes',

enabled: 'yes'

},

uri: 'http://admin:[email protected]:2113/projections/continuous',

multipart: [{body: projection.source}],

}, (error, response, body) => {

if (error) {

return console.error('upload failed:', error);

}

console.log('Upload successful!  Server responded with:', JSON.stringify(response, null, 2));

});

}

What is body?

Okay, looks like I needed to add headers and NOT use multipart encoding: This last one worked :slight_smile:

request({

method: ‘POST’,

headers: {

‘Content-Type’: ‘application/json;charset=UTF-8’

},

qs: {

name: projection.name,

emit: ‘yes’,

checkpoints: ‘yes’,

enabled: ‘yes’

},

uri: ‘http://admin:[email protected]:2113/projections/continuous’,

body: projection.source,

}, (error, response, body) => {

if (error) {

return console.error(‘upload failed:’, error);

}

console.log(‘Upload successful! Server responded with:’, JSON.stringify(response, null, 2));

});

}