Can't close alert by alias when slash is used in alias

api̇

#1

If we create an alert that has a slash in it, for example 'somepath=/' then the alert can no longer be closed by alias.
When accessing this URL:
https://api.opsgenie.com/v2/alerts/somepath%3D%2F/close?identifierType=alias
we get "Request will be processed" but if we check the request we see that:
“status”: “There is no open alert with alias [somepath=].”,
“success”: false
What am I missing here, isn’t URL encoding supposed to work like that?


#2

Have you fixed your problem? I have a similar problem…


#3

I worked around the problem by making sure that alert ids don’t end with a slash, but it is an opsgenie API error that only they can fix.


#4

Hi Cristian,

As long as the alias is encoded before the alert is created (via our urlEncode() method or an external library), the URL you posted above should work when closing the alert.

For example, if the alert is created through one of our built-in integrations, adding our .urlEncode() method to the alias field should do that:

That will change alias=ThisIs/ASlash to alias=ThisIs%2FASlash during alert creation.
Hope this helps!


#5

That makes sense but the problem is that it is not obvious that one should URL encode aliases.On alert creation the alias goes into the json body sent via POST so there is no URL encoding constraint, this should be necessary only when the alias is passed as an URL parameter.