I would like to set the Executive Summary in a Post Mortem via the API. I am using Python. There is an API function for it, but unfortunately there is no curl example. Usually with a curl example I can verify that my syntax and formatting works on the commandline and then transfer to Python.
Does anybody have an example that works?
Here is a snippet of what I am trying to accomplish. The error code that I get when running this is HTTP Error 422: Unprocessable Entity
postmortemid = "0..........8"
initialURL = "https://api.opsgenie.com/v2/postmortem/"
URL = initialURL + postmortemid + "/executive-summary"
jsondata = {"type":"adf","executivesummary":{"content":[{"type":"heading","attrs":{"level":4},"content":[{"type":"text","text":"Leadup"}]}],"type":"doc","version":1}}
headers = {"Content-Type": "application/json", "Authorization": og_key}
try:
data = json.dumps(jsondata)
bindata = data if type(data) == bytes else data.encode('utf-8')
req = urllib.request.Request(URL, data=bindata, headers=headers, method='PUT')
result = urllib.request.urlopen(req)
if result.getcode() >= 200 and result.getcode() < 300:
messages = result.read()
json_obj = json.loads(messages)
print(json_obj)
else:
print("Non 200 code from OpsGenie", result.getcode())
except Exception as e:
print("Exception")
print(e)