Skip to main content
Solved

PagerDuty Integration Error: HTTP 400 Error when creating incident

  • November 14, 2025
  • 1 reply
  • 51 views

hmd
Forum|alt.badge.img+1

[What I want to achieve]

I would like to create an incident in PagerDuty.


[Problem]

When executing the action [Create Incident], the following error occurs and the incident cannot be created.

There was an error creating a new incident.400 Client Error: Bad Request for url: https://api.pagerduty.com/incidents


[What I did to resolve the issue]

- Check the settings

I ran TEST from [Integrations Setup] > [Configuration] and confirmed that it worked.

- Run Ping

I ran [IDE] > [PagerDuty] > [Ping] and confirmed that it worked.

 

Can someone help me to solve this problem?

Best answer by _K_O

Hi ​@hmd

 

When we were initially integrating with PD we had the same issue - the main problem was the difference between V1 and V2 APIs as the PD integration from the marketplace doesn’t use the latest API calls. To solve it I had to create a new action for the V2 API. I’ve included the custom action below - this works for my environment, YMMV:

 

from SiemplifyAction import SiemplifyAction
from SiemplifyUtils import unix_now, convert_unixtime_to_datetime, output_handler
from ScriptResult import EXECUTION_STATE_COMPLETED, EXECUTION_STATE_FAILED,EXECUTION_STATE_TIMEDOUT
import requests

@output_handler
def main():
siemplify = SiemplifyAction()

routing_key = siemplify.extract_action_param("Routing Key", print_value=False)
event_action = siemplify.extract_action_param("Event Action", print_value=True)
source = siemplify.extract_action_param("Source", print_value=True)
severity = siemplify.extract_action_param("Severity", print_value=True)
summary = siemplify.extract_action_param("Summary", print_value=True)

# https://developer.pagerduty.com/api-reference/368ae3d938c9e-send-an-event-to-pager-duty
url = "https://events.pagerduty.com/v2/enqueue"

payload = {
"payload": {
"summary": summary,
"severity": severity,
"source": source,
},
"routing_key": routing_key,
"event_action": event_action
}
headers = {
"Content-Type": "application/json",
"Accept": "application/json"
}

response = requests.post(url, json=payload, headers=headers)
siemplify.LOGGER.info('API Response: ' + response.text)

# If we see the string 'message' in the response, assume it completed. If not, then
# error out with the details provided by the API.
if 'message' in response.text:
status = 0
output_message = "Event sent to PagerDuty"
siemplify.result.add_result_json(response.text)
result_value = "Event sent to PagerDuty"
else:
status = 2
output_message = response.text
result_value = response.text

siemplify.LOGGER.info("\n status: {}\n result_value: {}\n output_message: {}".format(status,result_value, output_message))
siemplify.end(output_message, result_value, status)


if __name__ == "__main__":
main()

 

In terms of event actions, it was a list with the following values:
 

 

Severity had a similar list:

 

 

Hope this helps!

1 reply

_K_O
Forum|alt.badge.img+12
  • Bronze 5
  • Answer
  • November 14, 2025

Hi ​@hmd

 

When we were initially integrating with PD we had the same issue - the main problem was the difference between V1 and V2 APIs as the PD integration from the marketplace doesn’t use the latest API calls. To solve it I had to create a new action for the V2 API. I’ve included the custom action below - this works for my environment, YMMV:

 

from SiemplifyAction import SiemplifyAction
from SiemplifyUtils import unix_now, convert_unixtime_to_datetime, output_handler
from ScriptResult import EXECUTION_STATE_COMPLETED, EXECUTION_STATE_FAILED,EXECUTION_STATE_TIMEDOUT
import requests

@output_handler
def main():
siemplify = SiemplifyAction()

routing_key = siemplify.extract_action_param("Routing Key", print_value=False)
event_action = siemplify.extract_action_param("Event Action", print_value=True)
source = siemplify.extract_action_param("Source", print_value=True)
severity = siemplify.extract_action_param("Severity", print_value=True)
summary = siemplify.extract_action_param("Summary", print_value=True)

# https://developer.pagerduty.com/api-reference/368ae3d938c9e-send-an-event-to-pager-duty
url = "https://events.pagerduty.com/v2/enqueue"

payload = {
"payload": {
"summary": summary,
"severity": severity,
"source": source,
},
"routing_key": routing_key,
"event_action": event_action
}
headers = {
"Content-Type": "application/json",
"Accept": "application/json"
}

response = requests.post(url, json=payload, headers=headers)
siemplify.LOGGER.info('API Response: ' + response.text)

# If we see the string 'message' in the response, assume it completed. If not, then
# error out with the details provided by the API.
if 'message' in response.text:
status = 0
output_message = "Event sent to PagerDuty"
siemplify.result.add_result_json(response.text)
result_value = "Event sent to PagerDuty"
else:
status = 2
output_message = response.text
result_value = response.text

siemplify.LOGGER.info("\n status: {}\n result_value: {}\n output_message: {}".format(status,result_value, output_message))
siemplify.end(output_message, result_value, status)


if __name__ == "__main__":
main()

 

In terms of event actions, it was a list with the following values:
 

 

Severity had a similar list:

 

 

Hope this helps!