调用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=${来源分支}"