linode-python icon indicating copy to clipboard operation
linode-python copied to clipboard

Using API Correctly?

Open robertf57 opened this issue 8 years ago • 1 comments

I'm trying to use your Linode Python API but I'm getting an error I don't understand. Can you help me? I want to get a list of the disks attached to a particular linode using this code:

from linode import api as linode_api
api = linode_api.Api(<my_api_key>)
linode_id = 1800300
disks = api.linode_disk_list(linode_id)

When I execute the code, I get the following error:

TypeError: wrapper() takes exactly 1 argument (2 given)

I know I'm creating the api instance correctly as I'm using it to successfully call the API's linode_ip_list method. Interestingly, if I don't provide the linode_id argument, I get this error:

linode.api.MissingRequiredArgument: 'LinodeID'

If I call the method with a linode ID, the error says I'm giving it two arguments. But if I don't give it any arguments, it says I'm missing an argument. At this point, I'm not sure if the LinodeID should be an integer or a string but I get the same error in either case. How do I call this method so that I don't get the TypeError argument? Thank you for your help.

robertf57 avatar Apr 26 '16 18:04 robertf57

If I recall correctly, I think it wants to be:

api.linode_disk_list(LinodeID=linode_id)

Due to the flexible nature of the API Wrapper, it doesn't quite know what to do with positional arguments.

Give that a shot and see how it goes?

On Tue, Apr 26, 2016, at 14:36, Robert wrote:

I'm trying to use your Linode Python API but I'm getting an error I don't understand. Can you help me? I want to get a list of the disks attached to a particular linode using this code: from linode import api as linode_api api = linode_api.Api(<my_api_key>) linode_id = 1800300 disks = api.linode_disk_list(linode_id) When I execute the code, I get the following error:

TypeError: wrapper() takes exactly 1 argument (2 given)

I know I'm creating the api instance correctly as I'm using it to successfully call the API's linode_ip_list method. Interestingly, if I don't provide the linode_id argument, I get this error:

linode.api.MissingRequiredArgument: 'LinodeID'

If I call the method with a linode ID, the error says I'm giving it two arguments. But if I don't give it any arguments, it says I'm missing an argument. At this point, I'm not sure if the LinodeID should be an integer or a string but I get the same error in either case. How do I call this method so that I don't get the TypeError argument? Thank you for your help. — You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub[1]

Links:

  1. https://github.com/tjfontaine/linode-python/issues/32

rtucker avatar May 07 '16 15:05 rtucker