Last active
June 29, 2022 12:42
-
-
Save rogeriochaves/7d1430f67f867b4a615a1025e0a6a55a to your computer and use it in GitHub Desktop.
Shortcut to post json with curl from terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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