code 2001 "title cannot be empty"


(Joe Calcada) #1

Hi folks - I’ve been able to successfully create incidents in the developer V2 API reference site but then same json payload running within my python script generates a “2001 error”. I guess HAL is not happy :wink:

can someone see why this code segment would cause that issue ? (my Token is correct and gets applied properly within the developer web site and gets passed into the header correctly in my code below)

import requests
import os
headerstr = {‘Content-Type’: ‘application/json’, ‘From’: ‘’, ‘Authorization’: ‘Token token={token}’, ‘Accept’: ‘application/vnd.pagerduty+json;version=2’}
payloadhead = ‘{\n"incident": { \n “type”: “trigger”,\n’
servicestr =’ “service”: { \n “id”: “P2NMIJW”,\n “type”: “service_reference”\n },\n’
summarystr = ’ “title”: “this is title #1”,\n’
detailstr = ’ “body”: { \n “type”: “incident_body”, \n “details”: “This is detail info” \n }’
payload = payloadhead + summarystr + servicestr + detailstr + ’ \n } \n}’
r =, json=payload, headers=headerstr)

(Thomas Roach) #2

I’ve had a chat with our tier 2 team, and they’ve suggested that where you’ve written r =, json=payload, headers=headerstr), you should instead use r =, data=payload, headers=headerstr). Give that a try and get back to us with the results!

(Joe Calcada) #3

Yes it works! Thanks.

(Demitri Morgan) #4

FYI, the json keyword argument was meant for dict/list objects; one can pass an object to be automatically JSON-encoded that way versus encoding manually and sending the argument to data.