-
Notifications
You must be signed in to change notification settings - Fork 166
Open
Description
Using the gitlab REST api, I am able to successfully update the default_branch of a project:
curl --request PUT --header "PRIVATE-TOKEN: <SNIP>" --url 'https://gtlb.legacybank.com/api/v4/projects/43' --data "default_branch=dev/master"
response:
{
"id":43,
"description":null,
"name":"LEAF",
"name_with_namespace":"Digital Banking / LEAF / LEAF",
"path":"LEAF",
"path_with_namespace":"digital-banking/leaf/LEAF",
"created_at":"2022-01-05T21:15:23.670Z",
"default_branch":"dev/master",
...
}Using GitLabAPiClient, I'm attempting to set the DefaultBranch of a Project using:
var client = new GitLabClient("https://gtlb.legacybank.com", accessToken);
try
{
var project = await client.Projects.GetAsync(projectId); // projectId == 43
var projectUpdate = await client.Projects.UpdateAsync(project.Id, new UpdateProjectRequest(project.Name)
{
DefaultBranch = branchName, // branchname == dev/master
});
}
catch (GitLabException e)
{
var errorMsg = $"Unable to set default branch [{branchName}] at {projectId}: {e.Message}";
Console.Error.WriteLine(errorMsg);
return 1;
}Response:
GitLabApiClient.GitLabException: {"message":"403 Forbidden"}
at GitLabApiClient.Internal.Http.GitLabApiRequestor.EnsureSuccessStatusCode(HttpResponseMessage responseMessage)
at GitLabApiClient.Internal.Http.GitLabApiRequestor.Put[T](String url, Object data)
at GitLabApiClient.ProjectsClient.UpdateAsync(ProjectId projectId, UpdateProjectRequest request)
at CommandLineTools.SetDefaultBranchCommand.CommandHandler(String branchName, String projectId) in /Users/dustinreagan/code/legacy/LEAF/tools/CommandLineTools/Commands/Gitlab/SetDefaultBranchCommand.cs:line 43
In both cases, I'm using the same Gitlab Access Token and other parameters.
Any ideas?
Metadata
Metadata
Assignees
Labels
No labels