Skip to content

Possible bug with UpdateAsync in version 1.8.0? #252

@DustinReagan

Description

@DustinReagan

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions