hcgcloud / pterodactyl-sdk

Pterodactyl Panel PHP SDK/API wrapper
https://hcgcloud.github.io/pterodactyl-sdk-docs/
MIT License
27 stars 25 forks source link

Pterodactyl API - The given data failed to pass validation. #40

Closed dikovmaxim closed 2 years ago

dikovmaxim commented 2 years ago

Hello. I tried to implement automatic creation of server by using your API, but always, after I try to run $pterodactyl->createServer(... I get an error message that The given data did not pass the validation.

Here is the full response: object(GuzzleHttp\Psr7\Response)#31 (6) { ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=> string(20) "Unprocessable Entity" ["statusCode":"GuzzleHttp\Psr7\Response":private]=> int(422) ["headers":"GuzzleHttp\Psr7\Response":private]=> array(8) { ["Server"]=> array(1) { [0]=> string(12) "nginx/1.18.0" } ["Content-Type"]=> array(1) { [0]=> string(16) "application/json" } ["Transfer-Encoding"]=> array(1) { [0]=> string(7) "chunked" } ["Connection"]=> array(1) { [0]=> string(10) "keep-alive" } ["Cache-Control"]=> array(1) { [0]=> string(17) "no-cache, private" } ["Date"]=> array(1) { [0]=> string(29) "Sun, 26 Sep 2021 13:11:38 GMT" } ["X-RateLimit-Limit"]=> array(1) { [0]=> string(3) "240" } ["X-RateLimit-Remaining"]=> array(1) { [0]=> string(3) "236" } } ["headerNames":"GuzzleHttp\Psr7\Response":private]=> array(8) { ["server"]=> string(6) "Server" ["content-type"]=> string(12) "Content-Type" ["transfer-encoding"]=> string(17) "Transfer-Encoding" ["connection"]=> string(10) "Connection" ["cache-control"]=> string(13) "Cache-Control" ["date"]=> string(4) "Date" ["x-ratelimit-limit"]=> string(17) "X-RateLimit-Limit" ["x-ratelimit-remaining"]=> string(21) "X-RateLimit-Remaining" } ["protocol":"GuzzleHttp\Psr7\Response":private]=> string(3) "1.1" ["stream":"GuzzleHttp\Psr7\Response":private]=> object(GuzzleHttp\Psr7\Stream)#36 (7) { ["stream":"GuzzleHttp\Psr7\Stream":private]=> resource(21) of type (stream) ["size":"GuzzleHttp\Psr7\Stream":private]=> NULL ["seekable":"GuzzleHttp\Psr7\Stream":private]=> bool(true) ["readable":"GuzzleHttp\Psr7\Stream":private]=> bool(true) ["writable":"GuzzleHttp\Psr7\Stream":private]=> bool(true) ["uri":"GuzzleHttp\Psr7\Stream":private]=> string(10) "php://temp" ["customMetadata":"GuzzleHttp\Psr7\Stream":private]=> array(0) { } } }

Here is the error message:

Fatal error: Uncaught HCGCloud\Pterodactyl\Exceptions\ValidationException: The given data failed to pass validation. in /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php:122 Stack trace: #0 /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(101): HCGCloud\Pterodactyl\Pterodactyl->handleRequestError() #1 /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(35): HCGCloud\Pterodactyl\Pterodactyl->request() #2 /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/Actions/ManagesServers.php(57): HCGCloud\Pterodactyl\Pterodactyl->post() #3 /var/www/html/engine/createserver.php(138): HCGCloud\Pterodactyl\Pterodactyl->createServer() #4 {main} thrown in /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php on line 122

Here is my code. I checked everything and it should work. $server = $pterodactyl->createServer([ "external_id" => '11', "name" => "test", "user" => 1, "egg" => $egg_id, "docker_image" => $egg->dockerImage, "skip_scripts" => false, "environment" => [ "SERVER_JARFILE" => "server.jar", "VANILLA_VERSION" => "latest" ], "limits" => [ "memory" => 256, "swap" => 0, "disk" => 1024, "io" => 500, "cpu" => 100 ], "feature_limits" => [ "databases" => 1, "allocations" => 2 ], "startup" => $egg->startup, "description" => "", "deploy" => [ "locations" => [$location_id], "dedicated_ip" => false, "port_range" => [] ], "start_on_completion" => true ]); print_r($server);

Thanks in advance!

dikovmaxim commented 2 years ago

First, I saw this https://github.com/hcgcloud/pterodactyl-sdk/issues/7 issue, but it didnt help

tyson239 commented 2 years ago

https://hcgcloud.github.io/pterodactyl-sdk-docs/exceptions/#validationexception