Error code 405 when using '/server/directory/. '



  • When using php to access the root directory using /server/directory/. (which is stated on http://scales.pufferpanel.com/docs/serverdirectorydirectory to list the base files) it throws the following error:

    Response HTTP Status Code : 405 Response HTTP Body : {"code":"MethodNotAllowedError","message":"GET is not allowed"}

    I am able to access other directories such as /server/directory/logs which outputs:

    [SUPER LONG ARRAY OF FILES]

    and a 200 response. The code I'm using is as follows:

    <?php
    
    $XAccessServer = "KEY";
    $XAccessToken = "KEY";
    
    $cURL = curl_init();
    
    curl_setopt($cURL, CURLOPT_URL, 'https://URL:5656/server/directory/.');
    curl_setopt($cURL, CURLOPT_CAINFO, getcwd()."\certs\https.pem"); /*Trusting a local copy of the self-signed cert*/
    curl_setopt($cURL, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($cURL, CURLOPT_HTTPHEADER, [
            "X-Access-Server: $XAccessServer",
            "X-Access-Token: $XAccessToken",
        ]
    );
    $data = curl_exec($cURL);
    
    if(!$data) {
        die('Error: "' . curl_error($cURL) . '" - Code: ' . curl_errno($cURL));
    } else {
        $data = json_decode($data);
        echo "<pre>".print_r($data, true)."</pre>";
    }
    
    curl_close($cURL);
    

    so if the error is in my code please correct me. The error only happens when using /directory/. even though this is documented to work.



  • The documentation for the Scales API is far from accurate or complete. I would recommend looking at the Scales source directly to determine its actual functionality.

    I can confirm that this issue exists in Scales and it is not just your code. You might want to try the curl version when troubleshooting to make sure it functions with a simple curl if your PHP code does not work right.



  • @puffrfish thank you for the confirmation. I will check the source. I managed to bypass this by using sftp and navigating to the folder manually. It gives the same result but requires some extra steps. If I find a fix to this issue would it be alright to post it?


Log in to reply
 

Looks like your connection to PufferPanel Community was lost, please wait while we try to reconnect.