I want to disable notifications that triggers based on threshold rules defined. I tried it using the Post API but getting 400 error.
API url: https://billingbudgets.googleapis.com/v1/billingAccounts/{billing_id}/budgets
request body:
Hi @abhi27
Here's a step-by-step guide to address your issue:
(1) Correct the API Request URL
Ensure you replace {billing_id} with your actual billing account ID in the API URL:
https://billingbudgets.googleapis.com/v1/billingAccounts/{billing_id}/budgets
If you're updating an existing budget, you need to append the budget ID to the URL:
https://billingbudgets.googleapis.com/v1/billingAccounts/{billing_id}/budgets/{budget_id}
(2) Adjust the Request Body to Disable Notifications
request_body = {
"displayName": "test-budget",
"budgetFilter": {
"projects": [
"projects/{project_id}"
],
"calendar_period": "QUARTER"
},
"amount": {
"specifiedAmount": {
"currency_code": "USD",
"units": 10
}
},
"thresholdRules": [
{
"thresholdPercent": 0.8,
"spendBasis": "CURRENT_SPEND"
}
]
# Note: Removed notificationsRule to disable notifications
}
(3) Use the correct HTTP Method (POST)
Here is a Python code example for making the API Call
from google.auth import default
from google.auth.transport.requests import Request
import requests
# Authenticate with Google Cloud
credentials, _ = default()
credentials.refresh(Request())
headers = {
'Authorization': 'Bearer ' + credentials.token,
'Content-Type': 'application/json',
}
# Make the API call
response = requests.post(
'https://billingbudgets.googleapis.com/v1/billingAccounts/{billing_id}/budgets',
headers=headers,
json=request_body
)
print(response.json())
I hope that helps
Regards
Mahmoud
Hi @mahmoudrabie ,
I already tried using the same request body while creating the budget. Budget has been created successfully, but how do I make sure the notifications are disabled or not?
Apart from this, can you help me the request body in order to enable the notifications using API?
Thanks,
Abhinav