본문 바로가기
Q&A2022년 6월 6일1분 읽기

curl 명령어 실전 사용법

전
전민규
조회 519댓글 1

curl로 API를 테스트하는 실전 사용법을 정리해주세요.

댓글 1

김김영삼4년 전

curl 실전 사용법:

# GET 요청
curl https://api.example.com/users

# POST (JSON)
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Kim","email":"kim@test.com"}'

# 인증 헤더
curl -H "Authorization: Bearer TOKEN" https://api.example.com/me

# 파일 업로드
curl -F "file=@image.jpg" https://api.example.com/upload

# 응답 헤더 보기
curl -I https://example.com

# 상세 디버그
curl -v https://example.com

# 리다이렉트 따라가기
curl -L https://short.url/abc

# 응답을 파일로 저장
curl -o output.html https://example.com

# 타임아웃
curl --connect-timeout 5 --max-time 10 https://api.example.com
Ctrl+Enter로 등록