简体   繁体   中英

Outputting response of curl request

I wrote a bash function which made a PUT request and printed the response as such:

foo() {
  echo "$(curl --request PUT "foo.com" ...)"
}

When I call this function from my shell, I only see the progress table (not the response). How do I fix my function so that it outputs the response of my PUT request ?

Try this one-liner. Works for me.

foo() { curl -o - -X PUT -H "Content-Type: application/json" -d '{"id": 1}' https://jsonplaceholder.typicode.com/posts/1 ; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM