I am implementing adding a monitor using Softlayer java client. Once executing creatObject(), it returns Athentication error. Please check my sample code below and let me know if you find any doubt. My user id is a super user(IBMxxxxx)which doesn't set a permission.
Error: com.softlayer.api.ApiException$Internal: Unable to create a new object of type SoftLayer_Network_Monitor_Version1_Query_Host. Make sure the authentication method is correct.(code: SoftLayer_Exception, status: 500)
private void AddMonitoringInfo() {
Long hardwareId = new Long(848429);
// Define Ip Address
String ipAddress = "173.192.36.250";
// Define Query Type (1 = SERVICE PING, 17 = SLOW PING)
Long queryTypeId = new Long(1);
// Define Response action id (1 = Do Nothing, 2 = Notify Users)
Long responseActionId = new Long(2);
// Define waitCycles 0 = Immediately, 1 = 5 Minutes, 2 = 10 Minutes, etc
Long waitCycles = new Long(1);
// Define SoftLayer_Network_Monitor_Version1_Query_Host service
Host.Service hostService = Host.service(client);
// Build a SoftLayer_Network_Monitor_Version1_Query_Host object that you
// wish to create
Host templateObject = new Host();
templateObject.setHardwareId(hardwareId);
templateObject.setIpAddress(ipAddress);
templateObject.setQueryTypeId(queryTypeId);
templateObject.setResponseActionId(responseActionId);
templateObject.setWaitCycles(waitCycles);
try {
Host result = hostService.createObject(templateObject);
Gson gson = new Gson();
System.out.println("Result : " + gson.toJson(result));
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
The issue that you got, is related to permissions.
Please check that the user with which you are trying to create the monitor has Manage Device Monitoring permission enabled.