嘗試通過 API 在 CircleCI 中創建背景關系。參考檔案:https ://circleci.com/docs/api/v2/#tag/Context
我創建了一個個人 api 令牌并根據要求編碼為 base64,以在基本身份驗證命令中使用。
我正在使用如下 curl 命令:
name: "Create Context"
command:
curl --request POST \
--url https://circleci.com/api/v2/context \
--header 'authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'content-type:' 'application/json' \
--data '{"name":"string","owner":{"id":"string","type":"organization"}}'
我收到如下錯誤:
Unable to parse YAML
mapping values are not allowed here
in 'string', line 23, column 36:
--header 'authorization: xxxxxxxxxxxxxxx ...
我嘗試在該行中為轉義字符加上雙引號,但仍然是同樣的錯誤。你能建議正確的方法嗎
uj5u.com熱心網友回復:
YAML 中的多行字串值語法不同。那里沒有反斜杠轉義換行邏輯。它應該去:
name: "Create Context"
command: >
curl --request POST
--url https://circleci.com/api/v2/context
--header 'authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxx'
--header 'content-type:' 'application/json'
--data '{"name":"string","owner":{"id":"string","type":"organization"}}'
與 YAML 一樣,字串的結尾由縮進指示。
請注意,YAML 決議不是由 CURL 本身完成的。您curl在 YAML 中有一個命令,而不是相反。至于決議 YAML 的周邊軟體,問題還不清楚。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/489586.html
上一篇:如何在Android中將POSTcurl請求轉換為Retrofit請求?
下一篇:沒有證書授權的mTLS
