Skip to content

Instantly share code, notes, and snippets.

@scar45
Created November 23, 2016 06:27
Show Gist options
  • Save scar45/ffd053cbee1d1190c9d4a92b236febd1 to your computer and use it in GitHub Desktop.
Save scar45/ffd053cbee1d1190c9d4a92b236febd1 to your computer and use it in GitHub Desktop.
Send a bash variable through a cURL post
#!/bin/bash
header="Content-Type: application/json"
FILENAME="/media/file.avi"
request_body=$(< <(cat <<EOF
{
"jsonrpc": "2.0",
"method": "Player.Open",
"params": {
"item": {
"file": "$FILENAME"
}
}
}
EOF
))
curl -i -X POST -H "$header" -d "$request_body" http://192.167.0.13/jsonrpc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment