Cannot trigger custom bitbucket pipeline via API request
Asked by Flo Ragossnig:

Although, I've been through many of the related questions here, I cannot figure out what I'm doing wrong.  

I've set up a test **repository** at [https://bitbucket.org/\<my-workspace\>/\<my-test-repo\>](#).  

Then I've added a **custom pipeline** *(bitbucket-pipelines.yml)*

```
image: atlassian/default-image:3

pipelines:
  custom:
    configure:
      - variables:
        - name: TENANTS
        - name: STAGE
      - step:
        name: configure-create-and-campus
        script:
          - chmod +x scripts/reconfigure.sh
          - scripts/reconfigure.sh some
          - scripts/reconfigure.sh other
```

*Triggering the pipeline manually from the Bitbucket Admin Interface works.*

Then I've created an **Access Token** for the repo with pipeline:write permissions.

Then I've tried to query against the Bitbucket API endpoint, like stated in your [REST API Docs](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-pipelines-post) via Postman. The Authorization Bearer Token has been added.

Endpoint: *<https://api.bitbucket.org/2.0/repositories/>\<my-workspace\>/\<my-test-repo\>/pipelines/*   

My request body looks like so  

```
{

  "target": {

    "ref_type": "branch",

    "type": "pipeline_ref_target",

    "ref_name": "master",

    "selector": {

      "type": "custom",

      "pattern": "Using parameter for tenants"

    }
 
  },

  "variables": [

    {

      "key": "TENANTS",

      "value": "[\"codeversity.com\",\"sycademy.com\",\"heartbase.at\",\"tangoamadeus.com\", \"verbund.sycademy.com\",\"kaidoo.com\",\"blockademy.net\",\"oecademy.codeversity.com\",\"neeom.codeversity.com\",\"hb-tischler.heartbase.at\"]"

    },

    {

      "key": "STAGE",

      "value": "testing"

    }

  ]

}
```

Unfortunately, the request I get is always  

```
{

  "error": {

    "message": "Bad request",

    "detail": "bitbucket-pipelines.yml not found.",

    "data": {

      "key": "result-service.pipeline.yml-not-found",

      "arguments": {}

    }

  }

}
```

Any ideas?

Any help much appreciated! ?


Answers:
author: Flo Ragossnig
body: I found the solution - and I have to admit, that it pretty obvious ?  

I have set the wrong pipeline name as a pattern:  

```
pipelines:
  custom:
    configure: <-- this is the pipe name
      ...
```

so the request body should be

```
{

  "target": {

    "ref_type": "branch",

    "type": "pipeline_ref_target",

    "ref_name": "master",

    "selector": {

      "type": "custom",

      "pattern": "configure" <-- this is where the name goes

    }
 
  },
  ...
}
```

Maybe this helps someone!


author: Igor Stoyanov
body: [@Flo Ragossnig](/t5/user/viewprofilepage/user-id/5345686) hi.

This is a good idea to start using pipes. Here is an example of using a [trigger-pipeline](https://bitbucket.org/atlassian/trigger-pipeline/src/master/) pipe:  

```
  - pipe: atlassian/trigger-pipeline:5.3.0    variables:      BITBUCKET_USERNAME: $BITBUCKET_USERNAME      BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD      REPOSITORY: 'your-awesome-repo'
```

To discover more pipes, visit our [**Bitbucket Pipes Marketplace**](https://bitbucket.org/product/features/pipelines/integrations).

Regards, Igor

comments: author: Flo Ragossnig
body: Thanks, I've read this but unfortunately this does not solve the problem. I have set up everything already, it just does not work.


Tags: bitbucket-cloud

bitbucket-pipelines

cloud

rest-api