expect response

This commit is contained in:
zcong1993 2019-08-29 17:30:31 +08:00
parent 7dd8af3806
commit 5dccd96f34
1 changed files with 10 additions and 2 deletions

View File

@ -16,6 +16,14 @@ echo "body: $INPUT_BODY"
url="https://oapi.dingtalk.com/robot/send?access_token=${INPUT_DINGTOKEN}"
curl -s "$url" \
HTTP_RESPONSE=$(curl -s --write-out "HTTPSTATUS:%{http_code}" "$url" \
-H 'Content-Type: application/json' \
-d "${INPUT_BODY}"
-d "${INPUT_BODY}")
# extract the body
HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
if [ ! "$HTTP_BODY" = '{"errcode":0,"errmsg":"ok"}' ]; then
echo "Error Response: ${HTTP_RESPONSE}"
exit 1
fi