curl 参数以文件形式上传

curl -s -X POST -H 'Content-Type:application/json' -d@export-dashboard-new.json http://${host}/zabbix/api_jsonrpc.php -v

  • -X 参数代表资源的请求类型
  • -H参数表示在请求头中附加的参数
  • -d参数表示需要上传的参数,需要上传文件时需要使用@file_name
  • -v 查看curl执行过程中的详细信息
  • -s, --silent
     Silent or quiet mode. Don't show progress meter or error messages.  Makes Curl mute.
     

curl -s -X POST -H 'Content-Type:application/json' -d@export-dashboard-new.json http://${host}/zabbix/api_jsonrpc.php -v

提交POST请求,附带参数放在文件export-dashboard-new.json 中

 

更多详细信息,参考 man curl

      -d, --data <data>
              (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data  to
              the server using the content-type application/x-www-form-urlencoded.  Compare to -F, --form.

              -d, --data is the same as --data-ascii. To post data purely binary, you should instead use the --data-binary option. To URL-encode the value of a form field you may use --data-urlencode.

              If  any of these options is used more than once on the same command line, the data pieces specified will be merged together with a separating &-symbol. Thus, using '-d name=daniel -d skill=lousy' would generate a post
              chunk that looks like 'name=daniel&skill=lousy'.

              If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin.  The contents of the file must already be URL-encoded.  Multiple  files
              can also be specified. Posting data from a file named 'foobar' would thus be done with --data @foobar.
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值