Skip to navigation
Bash script what handles json POST GET
10.12.21
bash script what receive a restful data response, takes a value from the json data and and post it to an API. After all goes good, it will post a success report #!/bin/bash value=$(curl -X 'GET' 'http://api.foo.com/bar?f=ratio' | jq -r '.ratio') r=$(curl -d "{\"ratio\":$value}" -X POST http://api.foo.com/bar -H "Content-Type: application/json") echo $r if [ "$r" = '{"msg":"success"}' ]; then curl -X POST https://report.api.com/task -d task=bar fi
https://ryanstutorials.net/bash-scripting-tutorial/bash-if-statements.php
Reply
Anonymous
Information Epoch 1752527111
Save trees.
Home
Notebook
Contact us