cURLでPOSTするときにJSONのデータを持たせてステータスコードだけチェックする方法


endpoint_test.sh
#!/bin/sh

SUCCESS=200

# GET 
CODE=`curl -X GET -s -o /dev/null -w '%{http_code}\n' localhost:8000/endpoint
if [ $CODE -ne $SUCCESS ]; then 
  exit 1
fi

# POST w/ JSONファイル
CODE=`curl -X POST -s -o /dev/null -w '%{http_code}\n' -d @filename localhost:8000/endpoint`
if [ $CODE -ne $SUCCESS ]; then 
  exit 1
fi