Create new git branch: azure.devops.exceptions.AzureDevOpsClientRequestError: The requested resource does not support http method 'PATCH'
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start with azure/devops/released/git/git_client_base.py and the update_ref() entry point, then review the linked Azure DevOps REST API documentation and the supplied GitRefUpdate call. Determine whether branch creation is supported through this method or requires a separate API path, and document the valid inputs or missing client capability as the outcome.
Written by the indexing model from the issue text.
Description
Background:
I'm using the azure-devops-python-api - library in order to programmatically push a commit to my Azure DevOps organization (git) repository.
The Azure DevOps REST API docs for "Update - Ref" did not help me to figure out the solution.
This discussion did not help me either.
Problem:
"The requested resource does not support http method 'PATCH'" when calling update_ref() in module azure\devops\released\git\git_client_base.py.
There is no obvious function for creating a branch, which would be called create_branch() according to the principle of least surprise.
As opposed to this Azure DevOps API, this is much more intuitively resolved in e.g. the AWS CodeCommit API.
Anyways, I would like understand what exactly goes wrong here.
The error message is very generic, I could not determine which of the inputs are the problem.
Even when I provide the filter - argument instead of being None to the target or source branch name, it throws the following error:
azure.devops.exceptions.AzureDevOpsServiceError: The only property which can be patched is isLocked.
For the sake of completeness, the short docstring of filter from the above-mentioned module:
:param str filter: The name of the branch to lock/unlock
I would also be greatful for any other way of simply creating a new branch which does not exist.
Source Code:
The code involved until invoking the git_client.update_ref() - method, is:
from azure.devops.v5_1.git.models import (
GitRefUpdate,
)
from azure.devops.connection import Connection
release_head_commit_id = '12312314123123123213123123123'
project_name = 'project_x'
repo_name = 'project_x'
release_branch_name = 'target-branch'
feature_branch_name = 'feature-branch'
git_client = Connection(base_url=organization_url, creds=credentials).clients.get_git_client()
filter_name = None # or feature_branch_name or release_branch_name alternatively
git_client.update_ref(
GitRefUpdate(
is_locked=False,
name=feature_branch_name,
new_object_id=release_head_commit_id,
old_object_id='0' * 40,
repository_id=repo_name,
),
repo_name,
filter_name ,
project=project_name,
project_id=project_name,
)
The old_object_id='0' * 40 was set like this based on this comment.
- Dominant language
- Python
- Stars
- 684
- Forks
- 218
- Avg merge
- 8d 10h
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/azure-devops-python-api
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in microsoft/azure-devops-python-api
Similar issues
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DiamondLightSource/dodal#2211 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openml/openml-python#1749 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sipyourdrink-ltd/bernstein#6191 ·