I am making this call to make comments to service now:
url = 'https://myinstance.service-
now.com/api/now/table/incident/' + sys_id
user = 'user'
pwd = 'pass'
headers = {"Content-
Type":"application/json","Accept":"application/json"}
# Do the HTTP request
response = requests.patch(url, auth=(user, pwd), headers=headers ,data="{\"work_notes\":\"" + comment + "\"}")
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
print(comment)
And this works when the comment variable is just one line, but with multiple lines it breaks, I removed the \n from string and it does work. So how do I process this request with multiple lines, I cant get rid of the spaces the comments have to look well formatted. The comment is coming from zendesk api.
The print statement after the if not status 200 prints as following with multiple lines:
this
is
a
test