簡體   English   中英

如何在shell腳本中請求curl http和解析JSON響應?

[英]How to request curl http and parse the JSON response in shell script?

URL=$(curl -i -X GET -H "Authorization: Basic token=" -H "Cache-Control: no-cache" -H "http://company url:8080/v1/organizations/wiley/environments/api-team-ci1/stats/apis?select=sum(is_error)&timeRange=01/24/2017%2002:00~01/25/2017%2006:00") 

URL應該返回一個JSON響應,我需要解析並獲取一些值。 甚至沒有得到curl命令的響應; 只獲得“curl:沒有指定URL!” 錯誤。 當我第一次嘗試這樣做時,請幫助我並指導。

您將URL作為參數傳遞給-H ,但它不是標題 - 在URL之前刪除-H

url=$(curl -i -X GET -H "Authorization: Basic token=" -H "Cache-Control: no-cache" \
"http://company url:8080/v1/organizations/wiley/environments/api-team-ci1/stats/apis?select=sum(is_error)&timeRange=01/24/2017%2002:00~01/25/2017%2006:00")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM