尝试使用 GitLab API 下载原始文件时如何解决 404 错误?

How do I troubleshoot a 404 error when trying to use the GitLab API to download a raw file?

我正在尝试使用 Terraform 从私人存储库下载原始文件。但是我收到 404 错误。

日志:

null_resource.manifest: Destroying... [id=8131279658604839368]
null_resource.manifest: Destruction complete after 0s
null_resource.manifest: Creating...
null_resource.manifest: Provisioning with 'local-exec'...
null_resource.manifest (local-exec): Executing: ["/bin/sh" "-c" "curl --location --header 'PRIVATE-TOKEN: REDACTED' -O './.terraform/REDACTED/src/manifest.yml' https://gitlab.com/api/v4/projects/REDACTED/repository/files/src%2Fmanifest.yml/raw?ref=REDACTED"]
null_resource.manifest (local-exec):   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
null_resource.manifest (local-exec):                                  Dload  Upload   Total   Spent    Left  Speed
null_resource.manifest (local-exec):   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to  port 80: Connection refused
null_resource.manifest (local-exec): 100    32  100    32    0     0     64      0 --:--:-- --:--:-- --:--:--    64
null_resource.manifest (local-exec): {"message":"404 File Not Found"}
null_resource.manifest: Creation complete after 1s [id=5357322425754425058]

我不确定 404 是否有效,或者连接被拒绝是否意味着我有错endpoint/token/port?

我不确定为什么会收到端口 80 连接被拒绝的消息。 URL 是 HTTPS,我使用的是 --location.

使用小写-o指定本地文件名。 您的大写 -O 不带参数,并指定您希望在保存输出时使用远程文件名。

我假设 curl 将 './.terraform/REDACTED/src/manifest.yml' 解释为要获取的第一个 url 而不是文件名。

如果您 运行 您的 curl 命令带有 -v 标志,您可能会亲眼看到。