cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Not a customer? Start a free trial

Click the Start a free trial link to start a 15-day SaaS trial of our product and join our community as a trial user. If you are an existing customer do not start a free trial.

AppDynamics customers and established members should click the sign in button to authenticate.

Controller (SaaS, On Premises)

Escaped double quotes in HTTP template

SOLVED
chanjch
Creator

Escaped double quotes in HTTP template

Hi,

 

Recently I found that the ${latestEvent.summaryMessage} and ${latestEvent.eventMessage} of Mobile App New Crash events will contains double quote " in the message.

This will broke our HTTP template which try to form HTTP payload in JSON format.

 

May I know how we can escape the double quote of the ${latestEvent.summaryMessage} and ${latestEvent.eventMessage} value?

Our payload template is somethings like:

{

    "summaryMessage": "${latestEvent.summaryMessage}",
    "eventMessage": "${latestEvent.eventMessage}",

    ...

}

 

Thank you.

 

Regards,

Jen

Tags (1)
By replying you agree to the Terms and Conditions of the AppDynamics Community.
Escaped double quotes in HTTP template
4 REPLIES 4
Atyuha.Pal
AppDynamics Team

Re: Escaped double quotes in HTTP template

Hi Jen,


Can you try 

'$esc.java(${latestEvent.summaryMessage})' 

Reference: https://velocity.apache.org/tools/2.0/apidocs/org/apache/velocity/tools/generic/EscapeTool.html

You should have single quotes surrounding the key and values in json payload.

If it doesnt work try - $!{latestEvent.summaryMessage.replace('"',"")}

 

Thanks,

Atyuha



Found something helpful? Click the Accept as Solution button to help others find answers faster.
Liked something? Click the Thumbs Up button.
chanjch
Creator

Re: Escaped double quotes in HTTP template

Hi Atyuda,

 

Thanks for the reply.

 

I tried with

{

#set ($newSummary = '$esc.java(${latestEvent.summaryMessage})')

"summaryMessage": "$newSummary"

}

and it returns the payload exactly with "summaryMessage": "$newSummary" 

 

I tried with:

{ "summaryMessage": "${latestEvent.summaryMessage}.replace('"','')" }

but return the same error "SyntaxError: Unexpected token R" which seems unable to convert the double quote.

 

No luck to successfully escpae the double quote so far.

The endpoint required the message to be send in a JSON format which is a double quote format.

Thus I try to set the variable first then only assign it in the json payload but doesn't seems to make it works.

 

Have you able to send out a HTTP template in JSON format that can escape the double quotes?

 

Regards,

Jen

chanjch
Creator

Re: Escaped double quotes in HTTP template

Finally I tested below is working:

{ "summaryMessage": "$!{latestEvent.summaryMessage.replace('"','')}" }

Thanks a lot!

theodore.newell
New Poster

Re: Escaped double quotes in HTTP template

This was really helpful, thanks!