Skip to content

Instantly share code, notes, and snippets.

@rogeriochaves
Last active June 29, 2022 12:42
Show Gist options
  • Save rogeriochaves/7d1430f67f867b4a615a1025e0a6a55a to your computer and use it in GitHub Desktop.
Save rogeriochaves/7d1430f67f867b4a615a1025e0a6a55a to your computer and use it in GitHub Desktop.
Shortcut to post json with curl from terminal
# Usage:
# post '{"name": "Mr Foo"}' https://myapi/register
#
post () {
local json="$1";
local url="$2";
shift 2;
curl -X POST -H "Content-Type: application/json" --data "$json" "$url" $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment