lsymds / hetznercloud-py

Python SDK for the new Hetzner cloud
MIT License
30 stars 12 forks source link

Fix wrong API call when `body` is `None`. #10

Closed nh2 closed 6 years ago

nh2 commented 6 years ago

We shoud not send a body in that case. Until now, the code sent json.dumps(None), which is the JSON null value.

That triggered the error response "root must be an object".

ghost commented 6 years ago

What call causes this issue? The assumption is that when you are posting you will ALWAYS have body content.

Qpilore commented 6 years ago
configuration = HetznerCloudClientConfiguration() \
        .with_api_key("HETZNER_API_KEY") \
        .with_api_version(1)
client = HetznerCloudClient(configuration)
all_servers_list = list(client.servers().get_all())
for server in all_servers_list:
    server.power_on()

I have all server object functions with this problem.

ghost commented 6 years ago

Okay, my tests don't show this problem but I've merged the fix in anyway. A little caution never hurt nobody!