软层:SoftLayer_Account::getAllBillingItems。当我将 "parentId" 作为 null 传递时获取空数组 []

Softlayer: SoftLayer_Account::getAllBillingItems. Getting Empty Array [] when i pass "parentId" as null

致力于 SoftLayer_Account::getAllBillingItems 传递过滤器,我在其中单独获取所有项目和所有子项目。但我只想要父项,所以我在过滤器中将 parentId 作为 null 包含在内,结果 一个空数组 。当我通过特定的 ParentId 时,我能够获得物品。

https://Username:API_KEY@api.softlayer.com/rest/v3/SoftLayer_Account/getAllBillingItems.json?objectFilter={"allBillingItems":{"nextBillDate": {"operation": "betweenDate","options":[{"name": "startDate","value": ["03/07/2017"]},{"name": "endDate","value": ["03/20/2017"]}]},"parentId": {"operation":  null}}}&objectMask=category;location;associatedChildren;associatedChildren.category

我试过传递 is null 但没有输出。 有人能帮我吗?获取parentId为null的所有item的操作是什么?

根据文档,您需要使用 "is null" 而不是 "null" 请参阅 https://sldn.softlayer.com/article/object-filters

我注意到您正在尝试获取 parent 计费项目及其 children,我更新了 object-mask 以减少检索的数据,请注意如果您正在处理大量数据。回顾how-solve-error-fetching-http-headers。您可以使用以下任何掩码:

objectMask=mask[id,parentId,category,location,associatedChildren.category]

objectMask=id;parentId;category;location;associatedChildren.category

但是,如果您只想获取 parent 个计费项目,则没有必要使用掩码,除非您需要类别和位置等数据,在这种情况下,您可以使用以下掩码:

objectMask=mask[category,location]

这最后会显示 parent 项的信息,包括类别和位置。

您应该能够使用以下 REST 调用获得 parent 计费项目及其 children。

https://<user_name>:<api_key>@api.softlayer.com/rest/v3/SoftLayer_Account/getAllBillingItems?objectFilter={"allBillingItems":{"nextBillDate":{"operation":"betweenDate","options":[{"name":"startDate","value":["03/07/2017"]},{"name":"endDate","value":["03/20/2017"]}]},"parentId":{"operation": "is null"}}}&objectMask=mask[id,parentId,category,location,associatedChildren.category]

考虑到一些 REST 客户端不支持字母之间的空格。最后,如果您有很多计费项目,我建议使用 result-limit 功能以避免超时错误。

参考资料: http://sldn.softlayer.com/article/rest http://sldn.softlayer.com/article/object-Masks https://sldn.softlayer.com/article/object-filters http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item

我建议您在继续之前先阅读文档

此致