나의 발자취

CURL이란? 본문

Backend

CURL이란?

달모드 2024. 10. 14. 10:47

CURL은 Command line에서 HTTP 요청을 보내고 서버 응답을 확인하는 도구이다. Postman은 이것의 gui 버전이라고 생각하면 된다. 

버그와 같은 이슈가 발견되어 지라를 작성할 때 CURL을 잘 사용한다.

 

curl GET 요청

curl <주소>

curl http://jsonplaceholder.typicode.com/posts
curl https://www.naver.com

 

 

curl POST 요청

curl -X POST -H <헤더정보>

 

서버에 POST 요청을 보낼 때 전송할 데이터를 지정을 하고 싶은 경우, -d 옵션을 쓰고 JSON 형식의 데이터를 적어주면 된다. (여기서 -d 는 data를 뜻한다.)

curl -X POST -H "Content-Type: application/json" -d '{실제 날릴 json 포맷}' 을 주면 된다.

curl -X POST -H "Content-Type: application/json" -d '{"title":"foo", "body": "bar", "userId":1}' http://jsonplaceholder.typicode.com/posts

 

 

 

 

Comments