【问题标题】:How can I set the environment variable in request header for curl?如何在 curl 的请求标头中设置环境变量?
【发布时间】:2021-06-10 16:08:41
【问题描述】:

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

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

不工作。

【问题讨论】:

    标签: bash curl http-headers environment-variables


    【解决方案1】:

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

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

    【讨论】:

    • --header "access_token: "${SOME_ENV_TOKEN}"" 确实有效。谢谢
    猜你喜欢
    • 2015-05-14
    • 1970-01-01
    • 2017-06-20
    • 2018-11-05
    • 1970-01-01
    • 1970-01-01
    • 2019-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多