调用gitlab API提示{"error":"ref is missing, ref is empty"},解决办法

Posted Hellxz博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了调用gitlab API提示{"error":"ref is missing, ref is empty"},解决办法相关的知识,希望对你有一定的参考价值。

问题复现

官方给的写法,以创建远程分支举例

curl --request POST --header "PRIVATE-TOKEN: ${私钥}" ${gitlab地址}/api/v4/projects/${目录名}%2F${仓库名}/repository/branches?branch=${新分支名}&ref=${来源分支}

返回错误信息

 {"error":"ref is missing, ref is empty"}

我尝试交换ref与branch的参数顺序,发现提示变成了branch is missing, branch is empty

解决办法

其实是官方文档写的不严谨,只需要在地址前后加上双引号就可以了

curl --request POST --header "PRIVATE-TOKEN: ${私钥}" "${gitlab地址}/api/v4/projects/${目录名}%2F${仓库名}/repository/branches?branch=${新分支名}&ref=${来源分支}"

以上是关于调用gitlab API提示{"error":"ref is missing, ref is empty"},解决办法的主要内容,如果未能解决你的问题,请参考以下文章