Is there any way to output whole webResponse.body (or part of it) into description without parsing it?
I have an automation rule that makes a web call to sentry. It returns a json with the following structure:
{
"id": 2123123123,
"count:": 22323,
"metadata": { "value" : "fsdfsdfsd", "title" : "some data" },
"lastSeen": "2026-22-11"
}
I want to put in into description as a code block
{code:json}
//same json as above
{code}
I can do it by dot notation with every field pair name:value, but it is boring, number of fields is too big and they can change.
Maybe there exists a json function like
{{webResponse.body.asText()}}
or at least
{{webResponse.body.metadata.asText()}}
that I can use for my purposes like this:
{code:json}
{{webResponse.body.asText()}}
{code}
Any suggestions? I think webResponse.body is a java class instance and it should have toString() function.
You should be just able to use {{webResponse.body}}
It provides invalid json text without " for field names and text values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried saving the source JSON with the Create Variable action as that will force it to plain text (i.e., no objects recognized) and then use the variable in your other action?
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @s_gridnevskii ,
Maybe a silly question but did you try the plain way "webResponse.body" directly? You may try to log {{webResponse.body}} and see if it works for you. If not, please share the output with us so we can help better.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried, but it reports something like this
{
id: 2123123123,
count: 22323,
metadata: { value: fsdfsdfsd, other, title : some data },
lastSeen: 2026-22-11
sometextwithcommas: sdd, ff:, ssd,
othertext:
}
If I decide to then split the string using commas I can run across fields like sometextwithcommas that contain commas and :
This means that the text cannot be not be reliably parsed into "name": "value" pairs and json in Jira Description will be invalid.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I checked the WebResponseBody class in Java and indeed it is not a collection, it is inherited from Object. And toString() implementation looks weird. So looks like the only possible way to output "key": "value" in automation rule is to list all possible keys in automation rule (Dot notation).
I tried to trick Jira into thinking that body is plain text by adding header Accept: text/plain, but unfortunately sentry does not support it.
Could not satisfy the request Accept header.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah probably the toString is not valid for you. Another idea came to my mind; can you try {{webResponse.body.asJsonObject("response")}} ? Since the body is able to came as String in a JSON format, but in script format; maybe that can work for you.
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.