use pipe for curl data

后端 未结 8 442
盖世英雄少女心
盖世英雄少女心 2020-12-23 13:26

I\'m trying to pass the cat output to curl:

$ cat file | curl --data \'{\"title\":\"mytitle\",\"input\":\"-\"}\' http://api

Bu

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-23 14:17

    This should also work

    curl -H "Content-Type: application/json" -d @data.json http://api
    

    Using -d forces curl to implicitly use POST for the request.

提交回复
热议问题