how to get curl to output only http response body (json) and no other headers etc

前端 未结 2 734
执念已碎
执念已碎 2021-01-31 01:12

I am using curl in a bash script to fetch the response of a service as below,

response=$(curl -isb -H \"Accept: application/json\" \"http://host:8080/some/resour         


        
2条回答
  •  既然无缘
    2021-01-31 01:52

    You are specifying the -i option:

    -i, --include

    (HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...

    Simply remove that option from your command line:

    response=$(curl -sb -H "Accept: application/json" "http://host:8080/some/resource")
    

提交回复
热议问题