gocd / gocd

GoCD - Continuous Delivery server main repository

Home Page:https://www.gocd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to trigger GoCD pipeline via API

mbhatia-mdsol opened this issue · comments

I am not able to trigger a pipeline using schedule option. I have checked the GoCD API document. It suggests using POST /go/api/pipelines/:pipeline_name/schedule. But on using this i am getting error: "404 Client Error: Not Found for url: https://gocd-stg.imedidata.net/go/api/pipelines/ctms_AWS_deployment_automation/schedule". The endpoint and credentials that I am using are working fine for other tasks like update and fetch pipeline details. Please help as I have tried so many things that are suggested on internet.

Hi @mbhatia-mdsol - other than double checking the capitalization of your pipeline name, do you have all of the headers suggested within the example at https://api.gocd.org/current/#scheduling-pipelines ?

e.g

curl -fsSL -X POST \
  -H "Authorization: bearer $GOCD_TOKEN" \
  -H 'Accept: application/vnd.go.cd+json' \
  -H "Content-Type: application/json" \
  https://gocd-stg.imedidata.net/go/api/pipelines/ctms_AWS_deployment_automation/schedule \
  -d '{}'

You'll get a 404 if you don't have the right Accept header. The error message looks like Python, so if you can't figure it out perhaps you can share the relevant code snippet you're using.

A common mistake is sharing some code or script from elsewhere that had a different version number in the Accept header, e.g application/vnd.go.cd.v2+json vs application/vnd.go.cd.v1+json.

Since the APIs are versioned independently, that doesn't work reliably. Each URL/API either needs its own version number you accept, or if you don't care about the specific API response format/version, it's best to use application/vnd.go.cd+json without a version number which basically says "use the latest API version please".

The schedule and pipeline operations APIs don't have complex responses, so probably not a problem to accept latest version.