# Creating a https request from lambda from a curl req

**URL:** <https://discuss.circleci.com/t/creating-a-https-request-from-lambda-from-a-curl-req/26926>\
**Category:** Deployments\
**Tags:** api\
**Created:** [December 3, 2018, 5:28pm UTC](https://discuss.circleci.com/t/creating-a-https-request-from-lambda-from-a-curl-req/26926 "2018-12-03T17:28:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joha0033](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@joha0033](https://discuss.circleci.com/u/joha0033)\
**Post date:** [December 3, 2018, 5:28pm UTC](https://discuss.circleci.com/t/creating-a-https-request-from-lambda-from-a-curl-req/26926/1 "2018-12-03T17:28:49Z")

</div>

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](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](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=](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();
}
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [March 3, 2019, 5:41pm UTC](https://discuss.circleci.com/t/creating-a-https-request-from-lambda-from-a-curl-req/26926/2 "2019-03-03T17:41:04Z")

</div>

Closed on March 3, 2019, 5:41pm UTC

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