AnsweredAssumed Answered

v6.5 API returns nothing

Question asked by Oliver Marshall on Nov 1, 2015
Latest reply on Nov 3, 2015 by Dhaivat Naik

Hi all


I'm doing my first Hello World REST query and I'm falling over before I've even started to walk.


When I test my PHP script - which just attempts to login - the HTML source shows the <pre> tags but there's nothing in between them. I've checked the URL and it gives me a text based REST 'help' page and the username and password are correct (all redacted to protect the innocent).


Any ideas?



$url = "";

    $username = "admin";

    $password = "MySecretPassword";



    //function to make cURL request

    function call($method, $parameters, $url)



        $curl_request = curl_init();



        curl_setopt($curl_request, CURLOPT_URL, $url);

        curl_setopt($curl_request, CURLOPT_POST, 1);

        curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

        curl_setopt($curl_request, CURLOPT_HEADER, 1);

        curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);

        curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);

        curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);



        $jsonEncodedData = json_encode($parameters);



        $post = array(

             "method" => $method,

             "input_type" => "JSON",

             "response_type" => "JSON",

             "rest_data" => $jsonEncodedData




        curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);

        $result = curl_exec($curl_request);




        $result = explode("\r\n\r\n", $result, 2);

        $response = json_decode($result[1]);




        return $response;




    //login -----------------------------------------

    $login_parameters = array(

         "user_auth" => array(

              "user_name" => $username,

              "password" => md5($password),

              "version" => "1"


         "application_name" => "RestTest",

         "name_value_list" => array(),




    $login_result = call("login", $login_parameters, $url);




    echo "<pre>";


    echo "</pre>";