简体   繁体   English

输出卷曲请求的响应

[英]Outputting response of curl request

I wrote a bash function which made a PUT request and printed the response as such: 我编写了一个bash函数,该函数发出了一个PUT请求并按如下方式打印响应:

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 ? 如何修复我的函数,使其输出我的PUT请求的响应?

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 ; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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