Triggering Builds

Hi,

Im using the following request to trigger build on bitrise: (via nodejs)

{
method: ‘POST’,
url : “https://api.bitrise.io/v0.1/apps/{my application slug}/builds”,
headers:{
‘Content-Type’: ‘application/json’,
‘Authorization’: {my personal access token} //i do have permissions
},
json: true,
body:{
hook_info: {type: ‘bitrise’},
build_params: {
branch: {requested branch} ,
workflow_id: {requested workflow},
environments: [{env var 1 }, {env var 2} ]
}
}

I always get response of “Bad Request” and can’t figure out what am I doing wrong…
Appreciate your help !

Hello,

Have you tried using the Bitrise API Swagger page to verify your request? The “Try it out” option can be super helpful.

I will be honest here - I’m not a nodejs person so not sure if this is relevant - but should there be double quotes around the parameters?

{
“build_params”: {
“base_repository_url”: “string”,
“branch”: “string”,
“branch_dest”: “string”,
“branch_dest_repo_owner”: “string”,
“branch_repo_owner”: “string”,
“build_request_slug”: “string”,
“commit_hash”: “string”,
“commit_message”: “string”,
“commit_paths”: [
{
“added”: [
“string”
],
“modified”: [
“string”
],
“removed”: [
“string”
]
}
],
“diff_url”: “string”,
“environments”: [
{
“is_expand”: true,
“mapped_to”: “string”,
“value”: “string”
}
],
“head_repository_url”: “string”,
“pull_request_author”: “string”,
“pull_request_head_branch”: “string”,
“pull_request_id”: “string”,
“pull_request_merge_branch”: “string”,
“pull_request_repository_url”: “string”,
“skip_git_status_report”: true,
“tag”: “string”,
“workflow_id”: “string”
},
“hook_info”: {
“type”: “bitrise”
}
}

Thanks for your reply,
Basically in js you don’t have to use “key” but i gave it a try and for some reason it was the issue.
Thanks again!