Sending json files in curl requests with absolute or relative paths

前端 未结 1 1926
自闭症患者
自闭症患者 2020-12-29 22:04

Just wondering how I can send a curl command with the -d option specifying a file with its path and not a file in the current directory.

This is what I\'m getting wh

1条回答
  •  时光说笑
    2020-12-29 23:01

    The -d @ command option accepts any resolvable file path, as long as the path actually exists. So you could use:

    • a path relative to the current directory
    • a fully qualified path
    • a path with soft-links in it
    • and so on

    To wit, just the same as hundreds of other *Nix style commands. One quick note, the -d option will attempt to url encode your data, which from what you describe isn't actually what you want. You should use the --data-binary option instead. Something like this:

    curl -XPOST
         -H 'Content-Type:application/json'
         -H 'Accept: application/json'
         --data-binary @/full/path/to/test.json
         http://localhost:8080/easy/eservices/echo -v -s
    

    0 讨论(0)
提交回复
热议问题