Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Report variables as JSON in HTTP Post Payload

Alex K_ May 18, 2023

Hello, I am running into an issue. I am trying to use the Pattern utility to generate JSON which is then integrated into a larger JSON blob within my HTTP Payload. It looks like, according to the documentation, that the variable is auto-escaped when included in the payload section.

I am trying to generate a custom Slack webhook message, and I am getting invalid JSON errors when attempting to do this for example:

testreport = {"text":"test"}
Payload = {$testreport}

Is there any advice on this? Is there an equivalent for variables akin to the _html option like {$testreport_string} which does no modification to the data coming out of the report?

1 answer

0 votes
milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2023

@Alex K_ 

The report variable when fed through the http request payload is a string. Typically I will do a split by "\n" and process each line of the report accordingly. This will depend on your pattern.

Alex K_ May 18, 2023

The pattern I presented above has no "\n" characters. It is just a single line of JSON in a Trello variable being referenced in the payload.

From the documentation: 

Variables that are used in the URL are automatically URL-encoded to create valid URLs; variables used in the payload are automatically escaped to be part of a valid JSON string.

I am assuming that my would be valid JSON is getting converted to:

{\"text\":\"test\"}

 Which I unfortunately don't want.

milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2023

@Alex K_ 

{$reportvariable} by itself is a string and the value depends on the your criteria and pattern in your command. You can use it is a payload in http request e.g {"somekey" : "{$reportvariable}" } to your endpoint. 

Alex K_ May 18, 2023

That is unfortunately not the use case I am looking for. I guess my problem is more of a feature request then.

With a variable of:


{$reportvariable} == "text":"test"

I want to be able to have the payload be:


{"somekey":"hello world", {$reportvariable}}

Which would result in a payload of:


{"somekey":"hello world", "text":"test"}

 
I will try and look for a different solution.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events