Creating Deployment via Platform API Failed 400

I try to create deployment via platform API based on the documentation here :

Since I use gitlab as git repository, here is my body request :

await axios
          .post(
            `${process.env.VERCEL_API_URL}/v13/deployments`,
            {
              name: "Initial deployment",
              project: vercelProjectId,
              gitSource: {
                type: "gitlab",
                ref: "main",
                projectId: vercelProjectId,
              },
            },
            {
              headers: {
                Authorization: `Bearer ${VERCEL_TOKEN}`,
                "Content-Type": "application/json",
              },
            }
          )
          .catch((err) => {
            console.error("Error when deploying project", err.response.data);
            return err;
          });

The response return error 400 with messages :

error: {
    code: 'incorrect_git_source_info',
    message: 'The provided GitLab repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.',
    gitlabError: '{"message":"404 Project Not Found"}'
  }

I’ve verified the project is successfully created with correct gitlab repo linked on my vercel dashboard. I also verify the projectId is already correct.

The main branch is also correct (I can select it when try to create manual deployment from dashboard).

Additional Info :

  • Gitlab repo is private
  • I’ve already have success deployment with the same repo and branch, but by manual deployment from vercel dashboard
  • This project is also created from Platform API by following this docs

There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.

A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0.