Skip to content

404 error when attempting to create a new branch

Hello, I am encountering the following error when trying to create a new branch:

Error: Gitlab responded with a 404 status code: Request: { "endpoint": "/projects/50/repository/branches?branch=new-branch&ref=main", "method": "POST", "expectedStatusCode": 201 } Response: { "message": "404 Project Not Found" }

Here is how I am attempting to create the branch:

const gitlab = new Gitlab({
  privateToken: GITLAB_PAT,
  gitlabUrl   : [REDACTED],
});

const projects = await gitlab.findProjects({search: 'Test'});
const project = projects.find(project => project.name === 'Test');
const newBranch = await project?.createBranch('new-branch', 'main');

Should I be doing something different?