Skip to content

Instantly share code, notes, and snippets.

@gabrielbidula
Created December 2, 2019 09:11
Show Gist options
  • Save gabrielbidula/b564647d50ae7607807f10aa635b8d1b to your computer and use it in GitHub Desktop.
Save gabrielbidula/b564647d50ae7607807f10aa635b8d1b to your computer and use it in GitHub Desktop.
shellscript to send post requests in a curl loop
#!/bin/bash
array=('{
"product_id": "",
"name": "Private Austria (20.00%)",
"description": "Private Austria (20.00%)",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 1,
"total_cycles": 0,
"pricing_scheme": {
"fixed_price": {
"value": "8",
"currency_code": "EUR"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "8",
"currency_code": "EUR"
},
"setup_fee_failure_action": "CANCEL",
"payment_failure_threshold": 1
},
"taxes": {
"percentage": "20",
"inclusive": false
}
}'
'{
"product_id": "",
"name": "Private Belgium (21.00%)",
"description": "Private Belgium (21.00%)",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 1,
"total_cycles": 0,
"pricing_scheme": {
"fixed_price": {
"value": "8",
"currency_code": "EUR"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "8",
"currency_code": "EUR"
},
"setup_fee_failure_action": "CANCEL",
"payment_failure_threshold": 1
},
"taxes": {
"percentage": "21",
"inclusive": false
}
}'
)
for element in "${array[@]}"
do
curl -X POST \
https://api.paypal.com/v1/billing/plans \
-H 'Accept: */*' \
-H 'Authorization: Bearer XXX' \
-H 'Content-Type: application/json' \
-H 'Host: api.paypal.com' \
-d "${element}" >> output.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment