nugawiki

./categories/server

cURL HTTP GET/POST

업데이트 2026-07-21 조회수

cURL 설치

sudo apt-get install curl

GET/POST 호출

자주 쓰는 옵션: -d(전송 데이터), -H(헤더), -X(메소드)

# GET (URL형식 데이터)
curl -d "key1=value1&key2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X GET http://localhost:8000/data

# POST (URL형식 데이터)
curl -d "key1=value1&key2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:8000/data

# POST (JSON 데이터)
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:8000/data

# Windows curl: 작은따옴표(') → 큰따옴표("), 큰따옴표(") → 이스케이프("")로 변경
curl -d "{""key1"":""value1"", ""key2"":""value2""}" -H "Content-Type: application/json" -X POST http://localhost:8000/data

./comments