Forum Discussion
3 years ago
Stuart,
The script that we have is built around groovy, but is just something that is pieced together.
// instantiate an http client object for the target system
ip="api.ultradns.com"
httpClient = HTTP.open(ip, 443);
user = hostProps.get("ultradns.user");
pass = hostProps.get("ultradns.pass");
// use an authentication API call to initiate a session
// specify the url to which we want to post
url = "https://"+ip+"/authorization/token";
def payload = '{"username":"myusername","typeId":"com.tintri.api.rest.vcommon.dto.rbac.
RestApiCredentials","password":"mypassword"}';
// do the post
def postResponse = httpClient.post(url, payload,["Content-Type":"application/json"]);
// does the response indicate a successful authentication?
if ( !(httpClient.getStatusCode() =~ /200/) )
{
// no -- report an error, and return a non-zero exit code
println "authentication failure";
return(1);
}
// we are now authenticated. Subsequent GETs with the httpClient will pass in the session cookie
url="https://"+ip+"/reports/dns/usage_summary";
def getResponse=httpClient.get(url);
// print some data
println httpClient.getResponseBody();
With the params ultradns.user and ultradns.pass being values I pass into the script. I can show you what we have written on the postman side that is calling the data from Ultra that works if needed. Again, I apologize for being a novice at this but this is my first time working with an API into LogicMonitor.
Related Content
- 8 months ago
- 5 hours ago
- 2 years agoAnonymous
- 10 months ago