HI,
I am trying to send an web request API to a status page we have and when there is a single line of text in the custom field it works however if you add any new lines the request fails with BAD REQUEST
e.g - working
No business impact. No customer impact
e.g - Not Working
No Business impact
No Customer Impact
What do i need to change to the "incident_details" part to make multiple lines work in the API web request!? (it's also the same with Business /Customer impact but the fix for this will apply here)
Here is my API Call
{ "statuspage_id": "XYZ",
"incident_id": "{{issue.customfield_14416}}",
"incident_details": "\n Incident Update: {{issue.customfield_14408}} \n \n Business/Customer Impact: {{issue.customfield_14409}} \n \n Next Update: We will provide a further update in {{issue.customfield_14414}}.\n \n Incident Manager: {{issue.customfield_13934}} \n \n Impact Start time: {{issue.Customfield_14410.mediumDateTime}}",
"message_subject": "Incident Update: {{issue.summary}}",
"notify_email": "1",
"notify_sms": "0",
"notify_webhook": "0",
"social": "0", "irc": "0",
"msteams": "0",
"slack": "0",
"current_status": {{currentstatusvalue}},
"current_state": {{currentstatevalue}}
}
the newline characters (\n
) in your custom field are causing the JSON to become invalid. You can use .escaprJson function to escape special characters like new line in you case
{{issue.customfield_14408.escapeJson}}
if it does not work you might want to escape characters by replacing them
"incident_details": "{{issue.customfield_14408.replace("\n", "\\\\n")}}",
Hi @Tuncay Senturk
Ive updated it like this and now the value is empty, any ideas?
"incident_details": "\n Incident Update: {{issue.customfield_14408.escapeJson}} \n \n Business/Customer Impact: {{issue.customfield_14409}} \n \n Next Update: We will provide a further update in {{issue.customfield_14414}}.\n \n Incident Manager: {{issue.customfield_13934}} \n \n Impact Start time: {{issue.Customfield_14410.mediumDateTime}}",
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you try replacing \n characters as below?
"incident_details": "{{issue.customfield_14408.replace("\n", "\\\\n")}}",
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No im still getting request, have i got this right?
"incident_details": "\n Incident Update: {{issue.customfield_14408.replace("\n", "\\\\n")}} Business/Customer Impact: {{issue.customfield_14409}} \n \n Next Update: We will provide a further update in {{issue.customfield_14414}}.\n \n Incident Manager: {{issue.customfield_13934}} \n \n Impact Start time: {{issue.Customfield_14410.mediumDateTime}}",
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, let's try one more thing
"incident_details": "{{issue.customfield_14408.replace('\n', '\\\\n')}}",
or this
"incident_details": "{{issue.customfield_14408.replace('\n', '\\n')}}",
I apologize; I should have recreated the content and written it accordingly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi I tried this but i got an error in the audit log
it was unable to pull a value from the customfield
Do you have anymore suggestions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I could not understand how it was unable to pull a value from the customfield?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
{
"statuspage_id": "xyz",
"incident_id": "{{issue.customfield_14416}}",
"incident_details": "{{issue.customfield_14408.replace('\n', '\\n')}}",
"message_subject": "Incident Update: {{issue.summary}}",
"notify_email": "1",
"notify_sms": "0",
"notify_webhook": "0",
"social": "0",
"irc": "0",
"msteams": "0",
"slack": "0",
"current_status": {{currentstatusvalue}},
"current_state": {{currentstatevalue}}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you certain that the custom field contains values for the issues? If it is empty or null, we may encounter an error, so it’s advisable to check if it has a value first.
{{#if(issue.customfield_14408)}}{{issue.customfield_14408.replace("\n", "\\n")}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The field has 2 lines of text in it so is not empty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I quickly set up an Automation rule testing both escapeJson and replace functions. Both work well, I'd suggest escapeJson as it creates json friendly string for your web requests which may cause problems (e.g. escape " character which has a meaning in Json)
However, I could not understand what is the issue in your case. I'd suggest tracing the web request and its payload, if we see what payload it produces, it will be easier to fix the problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.