I try to create deployment via platform API based on the documentation here :
https://vercel.com/docs/rest-api/endpoints#tag/deployments/create-a-new-deployment
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