Hello,
I am trying to update the status of a component using python and i am not able to get it to work. I am getting the following error
Helper python code
import requests
import json
class StatusPageHelper:
def __init__(self, url):
self.url = url
self.url_prefix = "https://" + url + "/v1/pages/"
self.session = requests.Session()
def updateStatusDashboard(self, token, page_id, component_id, status):
self.token = token
self.component_id = str(component_id)
self.page_id = str(page_id)
self.status = str(status)
print(self.url_prefix + page_id + "/components/" + self.component_id)
headers = {'Content-type': 'application/json', 'Authorization': 'OAuth ' + self.token}
self.data = json.dumps({"component[status]": "partial_outage"})
print(self.data)
self.session.headers.update(headers)
response = self.session.put(self.url_prefix + page_id + "/components/" + self.component_id, data=self.data, verify=False, timeout=30)
if response.status_code == 200:
print("{0}: Update success".format(self.url))
else:
print("{0}: Update failed: {1}".format(self.url, response.text))
Error:
api.statuspage.io: Update failed: {"error":"component is missing"}
Can someone help me to get the code to work or point me to the right direction as this is not helping. I printed the full url and it seems to be correct
I figured out my mistake and got it to work.
so how did you get it to work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also when i tried the same with Curl the command worked. So its kind of surprising that Python is not working
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.