1and1 / oneandone-cloudserver-sdk-php

Official mirror of the IONOS Cloud Server SDK for PHP.
Apache License 2.0
7 stars 5 forks source link

changeStatus() throws an error when trying to start, stop or reboot a server #10

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hello there. I am trying to power on/power off my servers using the API. However, calling the action POWER_ON / POWER_OFF results in an error:

{"type":"NOT_ALLOWED_ERROR","message":"","errors":"Not allowed operation: SERVERS_SHUTDOWN"}

I am a little confused, since I am calling POWER_ON / POWER_OFF and it returns SERVERS_START / SERVERS_SHUTDOWN in the JSON response. (Depending on what I am trying to do)

My code looks like this: _(Pretty much exactly like the example provided in the serverexamples.php file that comes with the SDK)

<?php

    # Path to the autoloader file
    require(__DIR__ . "/vendor/IONOS/vendor/autoload.php");
    use src\oneandone\oneandone;

    # New instance
    $client = new OneAndOne("<API_KEY>");
    $server = $client -> server();
    $action = [
        "action" => "POWER_ON",
        "method" => "SOFTWARE"
    ];
    $response = $server -> changeStatus($action, "<SERVER-ID>");

?>

I also tried setting the method to HARDWARE, but it didn't work either. Retrieving the current status of the server works perfectly fine.

I hope you can help me with this problem, thanks

ghost commented 4 years ago

Okay, nevermind.

I created a new group for the API-User in the Cloud Panel and didn't set the permissions.