Forum Discussion
endoceURIComponent() in javascript. Do that to your query parameter values.
encodeURIComponent()
We have AI that can paint the mona lisa, but it can't detect spelling errors?
- Anonymous8 months ago
Postman automatically encodes the values, but your JS might not be doing that. So if it works in postman with the ~, but not in your JS, you need to encode the string that contains the ~ using encodeURIComponent().
- Skeer8 months agoNeophyte
Hmm so that 'translates' to {{deviceHostname}}* at the destination however it would not work in a Jira 'Send web request' URL with a variable in the url string.
So the var won't get defined but instead passed as-is. I noticed Postman will send that encodes value as readily as the prior (name:"name-here*").
Any chance a filter can be part of the body?
- Anonymous8 months ago
No, the filter has to be in the query params. But i don't get why you can't do it. Mind posting your sanitized code?
- Skeer8 months agoNeophyte
So in a Jira automation rule there isn't 'code' in the traditional sense of the word. It's all visual like the application Tines.
This might help: https://imgur.com/a/oK61qK8
So what happens is there's a manual trigger, if the servicename == logicmonitor on the Incident in question then create a var: lmalertid from field 'issue.labels', print that to the audit log. Create a second var: deviceHostname from 'issue.customfield_20574', which is supplied from the ##host## token when the custom http delivery Active rule is triggered from LM.
Next we print that deviceHostname to the audit log, then send the first web request. The URL is https://xxxx.logicmonitor.com/santaba/rest/device/devices?filter=name:"{{deviceHostname}}*". The HTTP method is GET, with no body, and the following headers:
- Content-Type:application/json
- Authorization:Bearer <token>
- X-Version:3
- Cache-Control:no-cache
- User-Agent:Jira/JSM
- Accept:/
- Accept-Encoding:gzip, deflate, br
So provided LM sends the ##host## token, which defines the customfield_20574, and the rule can use that field to define {{deviceHostname}} and the URL is correctly formatted then it will throw the value of deviceHostname into the filter and send it.
I have other rules that successfully send these Jira variables in the body.. this is the first one I've tried using them in the URL.
Related Content
- 4 months ago