Hi All,
I'm trying to use HTTP POST to post a few variables from an alert, but the URL that I am trying to post to requires authentication. Can someone please tell me how to pass the credentials n the post message here?
Currently the Alert Manager's "Send a GET or POST request to a web server" alert action does not support authentication. I have logged this as a feature request internally under CORE-4308. In the meantime you could use the "Execute an external VB script" or "Execute an external program" alert actions and call your own custom script.
Thanks a lot aLTeReGo!
This is disappointing. I tried the VBScript option only to learn that you can't pass variables with a VBScript. Which makes either of these useless to me. Is there another option? I need to to POST to a REST URL WITH authentication and setup the message to be customized. I hate to have to use a web server in the middle to talk to another web server.
You can most definitely pass variables to your vbscript as shown below.
I realized that after trying it. You're reply didn't mention that and I assumed it meant you had to create a custom script to figure all of that out.
aLTeReGo,
Do you have a sample script to pass credentials? Appreciate if you can share.
Thanks.
Credentials stored in the credentials library cannot be passed as a variable/macro in an alert.
aLTeReGo,
In your respond to this question: In the meantime you could use the "Execute an external VB script" or "Execute an external program" alert actions and call your own custom script.:
I was wondering if you have a sample of this custom VB script?
Here is a simplified version of the script I am using:
On Error Resume NextIf WScript.Arguments.Count < 2 Then WScript.Echo "This script requires arguments." WScript.QuitEnd IfDim sURL, sAuth, sRequestTypesUrl = "">api.hostedservice.com/.../"sAuth = "myauthorizationstring"sRequestType = "POST"Dim sArg1, sArg2, sArg3, sBodysBody = "{""arg1"":""" & sArg1 & """,""arg2"":""" & sArg2 & """,""arg3"":""" & sArg3 & """}"sResponse = HTTPPost(sURL, sBody)WScript.Echo sResponseFunction HTTPPost(sURL, sRequest) Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP") oHTTP.open sRequestType, sURL, false oHTTP.setRequestHeader "Content-Type", "application/json" oHTTP.setRequestHeader "Content-Length", Len(sRequest) oHTTP.setRequestHeader "Authorization", "Basic " & sAuth oHTTP.send sRequest HTTPPost = oHTTP.responseTextEnd Function
jasongreb much appreciated! Will test this out.
3 years later and this trigger action still does not support credentials? When would you ever expose an unsecure api?
I'm interested in this as well.
--Patrick