LoginSignup
0
0

More than 3 years have passed since last update.

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

Posted at
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 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0