1.curl usage

For sending data with POST and PUT requests, these are common curl options:

  • request type

     -X POST

     -X PUT

  • content type header

     -H "Content-Type: application/x-www-form-urlencoded"

     -H "Content-Type: application/json"

  • data

     form urlencoded: -d "param1=value1&param2=value2" or -d @data.txt

     json: -d '{"key1":"value1", "key2":"value2"}' or -d @data.json

2. example

2.1 post urlencode binary data

curl -X POST --data-binary $'some_metric{label=\"val1\"} 42\n' " cat <

2.2 post json data

curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST  curl -d "@data.json" -X POST http://localhost:3000/data