Getting 500 Internal Server Error from Account.get

2019-09-02 23:29发布

I have been using a particular method for the past year and a half for loading the virtual guests from our account. Sometime in the past week, it broken. The following code (using ruby gem 3.1.1) returns a 500 Internal Server Error:

  softlayer_client = SoftLayer::Client.new()
  obj_svc = softlayer_client['Account']
  obj_svc = obj_svc.object_mask('mask[ id,tagReferences  ]')
  result = obj_svc.getVirtualGuests()
  result.each do |pre_obj|
    puts pre_obj.inspect
  end

But this does not:

  softlayer_client = SoftLayer::Client.new()
  obj_svc = obj_svc.object_mask('mask[ id  ]')
  result = obj_svc.getVirtualGuests()
  result.each do |pre_obj|
    puts pre_obj.inspect
  end

Seems like tagReferences was broken recently, since this has been working for a long time.

1条回答
Fickle 薄情
2楼-- · 2019-09-02 23:53

I've reviewed your first block of code and it works OK. Nevertheless, the problem that you're facing might be due to the number of objects that the method's returning, either virtual guests or tag objects. This can be avoided using a result_limit(OFFSET, LIMIT) as in the next example:

OFFSET = 0
LIMIT = 5
USERNAME = 'set me'
API_KEY = 'set me'
softlayer_client = SoftLayer::Client.new(username: USERNAME, api_key: API_KEY)
obj_svc = softlayer_client['Account']
obj_svc = obj_svc.object_mask('mask[ id,tagReferences  ]')
obj_svc = obj_svc.result_limit(OFFSET, LIMIT)
result = obj_svc.getVirtualGuests()
result.each do |pre_obj|
  puts pre_obj.inspect
end

If it doesn't solve your problem, try downloading the latest softlayer ruby client gem (i.e. 3.2.1)

You could review the next link as well:

https://sldn.softlayer.com/blog/phil/How-Solve-Error-fetching-http-headers

查看更多
登录 后发表回答