curl -Ls -o /dev/null -w %{url_effective} https://mapland.fr/echo
curl -d '{"message":"hello"}' -H "Content-Type: application/json" https://httpbin.org/post
echo '{"message":"hello"}' > file.json
curl -d @file.json -H "Content-Type: application/json" https://httpbin.org/post
How to generate customized / parameterized json from shell :
MSG="Hello world"
generate_json() {
cat <<EOF
{
"message": {
"content":"$MSG"
} x
}
EOF
}
curl -s -XPOST "https://httpbin.org/post" -H 'Content-Type: application/json' --data "$(generate_json)" | jq ".json"
curl -u "${BASIC_AUTH_USER}:${BASIC_AUTH_PASSWORD}" $URL
AUTH=$(echo -ne "${BASIC_AUTH_USER}:${BASIC_AUTH_PASSWORD}" | base64 --wrap 0)
curl \
--header "Content-Type: application/json" \
--header "Authorization: Basic $AUTH" \
--request POST \
--data '{"key1":"value1", "key2":"value2"}' \
$URL
curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
https://gitlab.com/api/v4/groups/givengroup/projects | \
-o repositories.json
curl --header "Authorization: Bearer xxxxxxxxx" https://somewhere.comm/
curl --insecure https://mapland.fr/
curl --insecure -vvI https://www.mapland.fr