From f7f94e1bfc75dbd69b836afa3f0cb6c66aa025d9 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 27 Aug 2024 20:11:37 +0100 Subject: [PATCH] Sending POST requests with curl --- source/_notes/16.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 source/_notes/16.md diff --git a/source/_notes/16.md b/source/_notes/16.md new file mode 100644 index 0000000..951ef52 --- /dev/null +++ b/source/_notes/16.md @@ -0,0 +1,29 @@ +--- +title: "Sending POST requests with curl" +date: 2024-08-27 20:11:37 +tags: [Linux, Command-Line, curl] +links: + - https://stackoverflow.com/questions/7172784/how-do-i-post-json-data-with-curl + - https://linuxize.com/post/curl-post-request +--- + +```shell +curl --header "Content-Type: application/json" \ + --insecure \ + --data '{"foo": "bar"}' \ + https://example.docker.localhost/webhook +``` + +`--request POST` is implied if `--data` is passed. + +`--insecure` skips SSL validation, e.g. if using a self-signed certificate. + +Also, from `man curl`: + +```shell +--json works as a shortcut for passing on these three options: + +--data [arg] +--header "Content-Type: application/json" +--header "Accept: application/json" +```