I'm trying to create an incident using the the StatusPage API. I'm getting the error:
{"error":"incident[components] is invalid"}
I'm attaching my script below but the crucial part is the payload which looks like this:
data = {
"incident[name]": "test",
"incident[impact_override]": "critical",
"incident[status]": "investigating",
"incident[body]": "test",
"incident[component_ids]": ["xxx"],
"incident[components]": {"xxx": "degraded_performance"}
}
No matter what I do or what I try, it won't work.
import requests
# Replace with your actual page ID and API key
page_id = "xxx"
api_key = "xxx"
# Data to send in the POST request
data = {
"incident[name]": "test",
"incident[impact_override]": "critical",
"incident[status]": "investigating",
"incident[body]": "test",
"incident[component_ids]": ["xxx"],
"incident[components]": {"xxx": "degraded_performance"}
}
# Headers with Authorization
headers = {
"Authorization": f"OAuth {api_key}"
}
# Send POST request
response = requests.post(url, headers=headers, data=data)
# Print response
print(response.status_code)
print(response.text)