我正在嘗試使用 curl API 請求獲取受 GitLab 保護的專案分支,獲取型別為“xyz”、“xyz-*”的所有相關分支。但我無法獲得名稱中包含“/”的分支。
使用以下 curl 請求,但分支“release/R*”失敗:
curl -H "Content-Type: application/json" --header "PRIVATE-TOKEN: <TOKEN>" "https://xyz.gitlab.com/tools/gitlab/api/v4/projects/492/protected_branches/'release/R*'"
它給出了一個輸出{"error":"404 Not Found"}
需要幫助來獲得所有分支的輸出,無論正則運算式如何,如果可能的話。
uj5u.com熱心網友回復:
要在 curl 請求中使用包含/您需要使用其編碼形式的分支的名稱/
改變
release/R
到
release/R
要對其進行測驗,請嘗試查詢單個分支(https://docs.gitlab.com/ee/api/branches.html#get-single-repository-branch)
對于名稱為 Eg 的分支release/Rated
curl --header "PRIVATE-TOKEN: <TOKEN>" "https://example.com/gitlab/api/v4/projects/<project_id>/repository/branches/release/Rated"
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/429044.html
