Ibm cloud infrastructure 使用Ruby的Sofloyer计费API-提取每个用户的计费详细信息
对Softlayer计费API有疑问。当我尝试运行API代码将数据提取到对象掩码时,我收到一个错误,如下所示: /Library/Ruby/Gems/2.0.0/Gems/softlayer\u api-3.2.1/lib/softlayer/apipParameterFilter.rb:82:inIbm cloud infrastructure 使用Ruby的Sofloyer计费API-提取每个用户的计费详细信息,ibm-cloud-infrastructure,Ibm Cloud Infrastructure,对Softlayer计费API有疑问。当我尝试运行API代码将数据提取到对象掩码时,我收到一个错误,如下所示: /Library/Ruby/Gems/2.0.0/Gems/softlayer\u api-3.2.1/lib/softlayer/apipParameterFilter.rb:82:inobject\u mask':object\u mask需要字符串(ArgumentError) from/Library/Ruby/Gems/2.0.0/Gems/softlayer\u api-3
object\u mask':object\u mask需要字符串(ArgumentError)
from/Library/Ruby/Gems/2.0.0/Gems/softlayer\u api-3.2.1/lib/softlayer/Service.rb:156:in
object\u mask'
来自testAuthentication\u old.rb:53:in`
require 'softlayer_api'
require 'pp'
user_id = "your user id"
api_key = "your API key"
object_mask = {"orderItem" => {"order" => {"userRecord" => {"username" => ""}}},
"invoiceItem" => {"totalRecurringAmount" => ""}}
billing = SoftLayer::Service.new("SoftLayer_Account",:username => user_id,:api_key => api_key)
user_bill=billing.object_mask(object_mask).getNextInvoiceTopLevelBillingItems
pp user_bill
for item in user_bill do
if item.key?("orderItem") &&
item["orderItem"]["order"]["userRecord"]["username"] == ""
pp("User " + "" + " has an invoice item of " +
item["invoiceItem"]["totalRecurringAmount"].to_s())
end`
身份验证工作正常,但不知何故,它抱怨对象掩码。你能提供一些见解吗。在Softlayer上的另一篇帖子中提到了改变计费API。如果是,是否需要以不同的方式定义对象遮罩?你能告诉我吗?任何帮助都将不胜感激。似乎需要对象掩码中的字符串,而不是指定示例中显示的对象
无论如何,请试试这个面具:
object_mask = "mask[orderItem[order[userRecord[username]]], invoiceItem[totalRecurringAmount]]"
billing = SoftLayer::Service.new("SoftLayer_Account",:username => user_id,:api_key => api_key)
user_bill=billing.object_mask(object_mask).getNextInvoiceTopLevelBillingItems
如果客户端不再支持其他掩码(对象类型),我将通知您。上述建议的更改有效。我们现在可以显示数据了。非常感谢你,鲁伯。感谢你的快速转变