Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug with UpdateAsync in version 1.8.0? #252

Open
DustinReagan opened this issue Nov 10, 2022 · 0 comments
Open

Possible bug with UpdateAsync in version 1.8.0? #252

DustinReagan opened this issue Nov 10, 2022 · 0 comments

Comments

@DustinReagan
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant