OS/Linux

리눅스 curl 기본 사용법

키키수수 2020. 8. 31. 16:05

호출 옵션

  -d, --data: <data> Send specified data in POST request.
  -H, --header: <header> Headers to supply with request.
  -X, --request: The request method to use. ex) GET, POST`

GET

  curl -d "key=value&key1=value1"
  -H "Content-Type: application/x-www-form-urlencoded"
  -X GET http://localhost/test

POST

  • QueryString

    curl -d "key=value&key1=value1"
    -H "Content-Type: application/x-www-form-urlencoded"
    -X POST http://localhost/test
  • JSON

    curl -d '{"key":"value", "key1":"value1"}'
    -H "Content-Type: application/json;charset=UTF-8"
    -X POST http://localhost/test

출처 : https://m.blog.naver.com/PostView.nhn?blogId=wideeyed&logNo=221350638501&proxyReferer=https:%2F%2Fwww.google.com%2F