@Nick Haller ,
I am using opsgenie python SDK (opsgenie-sdk==2.1.5) to Acknowledge alert, but I get "Body should be a JSON object" error response.
My function calling acknowledge_alert:
def acknowledgeAlert(self, request_id):
try:
response = self.alert_api.acknowledge_alert(identifier=request_id, identifier_type='id')
print("request status response :", response)
Response:
Traceback (most recent call last):
File "/Users/areif/Phoenix_Projects/victor_git/opsgenie_client_api/client.py", line 496, in <module>
response = opsgenie_client.acknowledgeAlert(request_id=alert)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/areif/Phoenix_Projects/victor_git/opsgenie_client_api/client.py", line 399, in acknowledgeAlert
response = self.alert_api.acknowledge_alert(identifier=request_id, identifier_type='id')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/opsgenie_sdk/api/alert/__init__.py", line 62, in acknowledge_alert
(data) = self.acknowledge_alert_with_http_info(identifier, **kwargs) # noqa: E501
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/opsgenie_sdk/api/alert/__init__.py", line 129, in acknowledge_alert_with_http_info
return self.api_client.call_api(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/opsgenie_sdk/api_client.py", line 423, in call_api
return self.__call_api(resource_path, method,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/opsgenie_sdk/api_client.py", line 251, in __call_api
raise exception
opsgenie_sdk.exceptions.ConfigurationException: You have configured something incorrectly: (400)
Reason: Bad Request: Invalid JSON body
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Date': 'Thu, 13 Jun 2024 11:46:55 GMT', 'X-Response-Time': '0.001', 'X-Ratelimit-State': 'OK', 'Og-Apigw-Request-Id': 'd179996e-b207-47b5-8ea4-67d3f801cd2f', 'Server': 'AtlassianEdge', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'Atl-Traceid': 'fc20c2cc0ae445b88a25a9cac2efb9ce', 'Strict-Transport-Security': 'max-age=63072000; preload', 'Report-To': '{"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}', 'Nel': '{"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}', 'Vary': 'Accept-Encoding', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 4850de46ab8614f257b88a6151d83804.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'BOM78-P5', 'X-Amz-Cf-Id': 'zTxUaxfra01X5KXRx6n1SPs3wP_kODE2bvCaCsC1M7UmCoVO-o_9yg=='})
HTTP response body: {"message": "Body should be a JSON object", "took": 0.001, "requestId": "20d2d8e5-04df-4669-a01a-0d2dd13ca963", "url": "https://api.opsgenie.com/v2/alerts/2a850d03-3a77-4db3-bb4a-96ac70b9748c-1718278346086/acknowledge"} I call similar API get_alert, which works fine,
try:
get_response = self.alert_api.get_alert(identifier=alert_id, identifier_type='id')
return get_response
except opsgenie_sdk.ApiException as err:
print("Exception when calling AlertApi->get_alert: %s\n" % err)
Only difference I find in the APIs is get_alert is GET and acknowledge_alert is POST.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.