I’m trying to use the Rest API to set branch protections.
Tests are all done via Swagger. Other Rest API calls work without problems.
But if i call [Patch] branch_protections, it returns “The target couldn’t be found.”
When i set an invalid owner, i get a proper message so i think the owner is not the problem.
I do have an organisation named testorg which has a repository testrepo
The repository has a branch named testbranch
The following is the curl command shown by swagger.
curl -X 'PATCH' \
'https://myservername.com/api/v1/repos/teamcity/testorg%2Ftestrepo/branch_protections/testbranch' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"approvals_whitelist_teams": [
"string"
],
"approvals_whitelist_username": [
"string"
],
"block_on_official_review_requests": true,
"block_on_outdated_branch": true,
"block_on_rejected_reviews": true,
"dismiss_stale_approvals": true,
"enable_approvals_whitelist": true,
"enable_merge_whitelist": true,
"enable_push": true,
"enable_push_whitelist": true,
"enable_status_check": true,
"merge_whitelist_teams": [
"string"
],
"merge_whitelist_usernames": [
"string"
],
"protected_file_patterns": "string",
"push_whitelist_deploy_keys": true,
"push_whitelist_teams": [
"string"
],
"push_whitelist_usernames": [
"string"
],
"require_signed_commits": false,
"required_approvals": 0,
"status_check_contexts": [
"string"
],
"unprotected_file_patterns": "string"
}'
This is the response i’m getting
Any idea what is wrong, or what is meant by target?