Creating a https request from lambda from a curl req

I can’t for the life of me figure out what I’m doing wrong, nor find any examples of creating a https request to CircleCI to trigger a build.
curl --user ${CIRCLECI_TOKEN}
–data build_parameters[CIRCLE_JOB]=deploy_docker
–data revision=$CIRCLE_SHA1
https://circleci.com/api/v1.1/project/github/joha0033/scyte-bot-cid/tree/dev

TO

Javascript using https request in lambda

I can get the parameters to work from Postman and trigger the build, but trying to get it triggered with Lambda using https… I’m missing something.

I’m only trying to trigger a { build_parameter: { CIRCLE_JOB: deploy_docker } }, but I keep getting a response saying, " first argument needs to be a string," from https.write()

what I have:
curl --user ${CIRCLECI_TOKEN}
–data build_parameters[CIRCLE_JOB]=deploy_docker
–data revision=$CIRCLE_SHA1
https://circleci.com/api/v1.1/project/github/joha0033/scyte-bot-cid/tree/dev

converted to…
const postOptions = {
path:‘https://circleci.com/api/v1.1/project/github/joha0033/scyte-bot-cid/tree/dev?circle-token=’ + process.env.CIRCLE_TOKEN,
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
},
body: {
“build_parameters”: {
“CIRCLE_JOB”: “deploy_docker”
}
}
};
const doDeploy = () => {
const postReq = https.request(postOptions, function(res) {
res.setEncoding(‘utf8’);
res.on(‘data’, (chunk) => {
console.log('Response: ’ + chunk);
});
})

    // post the data
    postReq.write(**[not sure what to put here?!]**);
    postReq.end();
}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.