Skip to content

Instantly share code, notes, and snippets.

@carymrobbins
Last active February 28, 2022 21:24
Show Gist options
  • Save carymrobbins/ff88a97c23b40e4c74597d72e6bab67b to your computer and use it in GitHub Desktop.
Save carymrobbins/ff88a97c23b40e4c74597d72e6bab67b to your computer and use it in GitHub Desktop.
Example curl to send a POST request with URL-encoded query params and a request body
% curl \
-XPOST https://httpbin.org/post \
-G \
--data-urlencode foo=bar \
--data-urlencode baz=quux \
-T <(echo -n '{"spam": "eggs"}')
{
"args": {
"baz": "quux",
"foo": "bar"
},
"data": "{\"spam\": \"eggs\"}",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
},
"json": {
"spam": "eggs"
},
"url": "https://httpbin.org/post?foo=bar&baz=quux"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment