bash - 如何在curl的请求 header 中设置环境变量?

标签 bash curl http-headers environment-variables

如何在curl的请求 header 中设置环境变量

curl --location --request POST 'test.example.com' \
--header 'Content-Type: application/json' \
--header 'access_token: "${SOME_ENV_TOKEN}"' \
--header 'Authorization: Basic Og=='

不工作。

最佳答案

使用 --header "access_token:\"${SOME_ENV_TOKEN}\""

' 引号禁用 sh 中的变量扩展。

关于bash - 如何在curl的请求 header 中设置环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67924837/

相关文章:

macos - 如何在 Mac OS X 上从终端启用用户帐户 SMB 共享?

linux - 移动文件和创建年月日文件夹时遇到问题

mysql - 在 Bash 中将 CSV 转换为 MySQL 更新语句

encoding - curl 请求中的字符已更改

python - 如何使用 python 请求(获取)和读取 xml 文件?

java - Java以静态方式访问数据

http - 如何在 HTTP 重定向上转发 header

nginx - NGinx $ proxy_add_x_forwarded_for和real_ip_header

linux - bash : no such file or directory when adding gradle to path on linux

amazon-web-services - 使用具有多个证书的 Invoke-WebRequest 在 PowerShell 中重写 CURL