Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

API Error When Creating Pipeline Schedule

Andrew Lehman February 9, 2022

Hello everyone,

I'm attempting to create a schedule for one of my repositories pipelines using this request:

curl -X POST -u '$USER:$PASSWORD' \
https://api.bitbucket.org/2.0/repositories/$WORKSPACE/$REPO/pipelines_config/schedules/ \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"type": "pipeline_schedule",
"enabled": true,
"target": {
"ref_type": "branch",
"type": "pipeline_ref_target",
"ref_name": "master",
"selector": {
"type": "custom",
"pattern": "stage"
}
},
"cron_pattern": "45 23 28 * *"
}'

However I keep getting this response:

{"error": {"message": "Request entity cannot be processed", "detail": "Unexpected response body", "data": {"key": "unexpected.response.body", "arguments": {}}}}

Does anyone have an idea of what I'm doing wrong?

Thank you

1 answer

1 accepted

7 votes
Answer accepted
Andrew Lehman February 11, 2022

Okay was talking to Bitbucket support in a ticket I submitted and with their guidance I was able to get this to work:

1. The Pipeline Schedules use an extended cron format (this is not documented in the API reference):

sec min hour day-of-month month day-of-week year

2. You need to use the "?" symbol instead of the "*" when leaving day-of-month or day-of-week blank

Armed with that knowledge the following request actually works and creates a pipeline schedule that runs at 4:45 UTC on the 28th day of every month

curl -X POST -u '$USER:$PASSWORD' \
https://api.bitbucket.org/2.0/repositories/$WORKSPACE/$REPO/pipelines_config/schedules/ \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"type": "pipeline_schedule",
"enabled": true,
"target": {
"ref_type": "branch",
"type": "pipeline_ref_target",
"ref_name": "master",
"selector": {
"type": "custom",
"pattern": "stage"
}
},
"cron_pattern": "0 45 4 28 * ? *"
}'
Sean Dean January 16, 2024

This just saved my bacon. Thank you!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events