删除要在Softlayer中通知的用户时出错

时间:2016-06-01 13:30:26

标签: ibm-cloud-infrastructure

当我删除要通知的用户时,它返回错误:com.softlayer.api.ApiException $ Internal:要删除的所有对象都必须设置ID。(代码:SoftLayer_Exception,status:500) 我已经设置了正确的UserId和DeviceId,但它仍然返回相同的错误。 这是我的示例代码。

private void deleteUserTonotify(){

    // Define the hardware and user identifiers
    Long hardwareId = new Long(164420);
    Long userId = new Long(538047);

    // Define SoftLayer_User_Customer_Notification_Hardware service
    com.softlayer.api.service.user.customer.notification.Hardware.Service hardwareService = com.softlayer.api.service.user.customer.notification.Hardware
            .service(client);

    // Declare SoftLayer_User_Customer_Notification_Hardware List
    List<com.softlayer.api.service.user.customer.notification.Hardware> templateObjects = new ArrayList<com.softlayer.api.service.user.customer.notification.Hardware>();


    com.softlayer.api.service.user.customer.notification.Hardware templateObject = new com.softlayer.api.service.user.customer.notification.Hardware();
    templateObject.setUserId(userId);
    templateObject.setHardwareId(hardwareId);

    // Add templateObject to templateObjects
    templateObjects.add(templateObject);

    try {
        boolean result = hardwareService.deleteObjects(templateObjects);
        System.out.println(" delete result : " + result);

    } catch (Exception e) {
        System.out.println("Error: " + e);
    }
}

1 个答案:

答案 0 :(得分:0)

数组中的每个对象必须至少定义其id属性。 您可以在下一个链接中找到更多信息: http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer_Notification_Hardware http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer_Notification_Hardware/deleteObjects

我已经在你的脚本中更改了它并且它可以工作:

<input type="file" name="pic" accept="image/*" id="pic" capture="camera">