Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rest Curl POST gitlab API提供404_Rest_Curl_Post_Gitlab_Gitlab Api_Jq - Fatal编程技术网

Rest Curl POST gitlab API提供404

Rest Curl POST gitlab API提供404,rest,curl,post,gitlab,gitlab-api,jq,Rest,Curl,Post,Gitlab,Gitlab Api,Jq,我正在尝试使用curl将一个名为“collections”的文件推送到存储库中的文件夹中。 我花了将近两天的时间调查这个问题,但我不确定到底是什么问题 curl -D- -k -X GET -H "PRIVATE-TOKEN: faNFKoC4-opiDJ0FJSk" https://gitlab.example.com/api/v4/projects/592/repository/tree?path=collections Get请求正常工作,我可以在collections文件夹中获取文件列

我正在尝试使用curl将一个名为“collections”的文件推送到存储库中的文件夹中。 我花了将近两天的时间调查这个问题,但我不确定到底是什么问题

curl -D- -k -X GET -H "PRIVATE-TOKEN: faNFKoC4-opiDJ0FJSk" https://gitlab.example.com/api/v4/projects/592/repository/tree?path=collections
Get请求正常工作,我可以在collections文件夹中获取文件列表。 collections文件夹是我的gitlab存储库中的一个文件夹 但当我试图将一个文件发布到完全相同的文件夹时,我得到了404:

curl -D- -k -X POST -H "PRIVATE-TOKEN: faNFKoC4-opiDJ0FJSk" -F "file=@C:/Documents/Folder_A/bp30_QA.csv" https://gitlab.example.com/api/v4/projects/592/repository/tree?path=collections
我是否缺少一些参数?而且gitlab API对我帮助不大

编辑:伯特兰·马特尔的解决方案帮助我解决了这个问题

同样适用于windows上安装jq时遇到问题的所有人

jq是一个轻量级且灵活的命令行JSON处理器

安装choco:

以管理员身份打开powershell并运行:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
安装后,运行:

choco install jq
要调用
collections
文件夹中的
bp30_QA.csv
,可以使用以下命令:

curl-H'PRIVATE-TOKEN:YOUR_PRIVATE_TOKEN'\
-H“内容类型:应用程序/json”\
-d'{
“分支”:“主”,
“作者电子邮件”:johndoe@gmail.com", 
“作者姓名”:“John Doe”,
“内容”:“$(jq-Rs.”“bp30_QA.csv)”,
“提交消息”:“创建新文件”
}' "https://gitlab.com/api/v4/projects/592/repository/files/collections%2Fbp30_QA.csv"

它用于将文件内容包装在单个JSON字段中(检查)

您是否尝试在URL周围加引号?(好习惯)。是的,我有,谢谢你的建议