curl 사용법 :: 행복한 프로그래머

posted by 쁘로그램어 2018. 5. 3. 21:57

CURL은 Client URL(Uniform Resource Locator)이며, 다양한 프로토콜위에서의 데이터 전송을 위해 필요한 라이브러리와 커맨드를 제공하는 소프트웨어라고 말할 수 있다.

클라이언트에서 커맨드 라인이나 소스코드로 손 쉽게 웹 브라우저 처럼 활동할 수 있도록 해주는 기술(커맨드라인 Tool 혹은 라이브러리)


# curl post example

$ curl -d '{"empNo":"E12","empName":"New Employee","position":"Clerk"}' -H "Content-Type: application/json" -X POST http://192.168.0.43:8080/employee


refer: https://gist.github.com/subfuzion/08c5d85437d5d4f00e58


# curl put example

$ curl -X PUT -H "Content-Type: application/json" -d '{"empNo":"E12","empName":"New Employee","position":"test"}' http://192.168.0.43:8080/employee


refer: https://stackoverflow.com/questions/13782198/how-to-do-a-put-request-with-curl


# curl delete example

$ curl -X DELETE http://192.168.0.43:8080/employee/E12


refer: https://www.garron.me/en/bits/curl-delete-request.html


# curl json pretty print

$ curl http://localhost:11608/api/v1.0/containers | python -m json.tool

$ curl http://localhost:11608/api/v1.0/containers | jq ''


※ 참고 사이트 ※

https://stackoverflow.com/questions/12943819/how-to-prettyprint-a-json-file