Jump to content

Dirkpitt

Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Posts posted by Dirkpitt

  1.  Hello @ 0xcffaedfe   
    to do a quick test, I put the two curl calls one below the other, but the result hasn't changed.
    as a first answer I got:

    HTTP Status Code: 200 Response Body: {"strAccessor":"Lxt1En2LCqqa45K4X0WeD2","PxgRetVal":20}

     

     

    as a second answer I get:

     

    HTTP Status Code: 200 Response Body: {"PxgError":{"code":1186,"file":"c:\\a\\b\\a_32ba8ed2\\s\\csadminkit\\development2\\std\\tmstg\\timeoutstore.cpp","line":211,"message":"Object \"Lxt1En2LCqqa45K4X0WeD2\" is absent","module":"KLSTD"}}

     

     

     how can i keep the session open? i tried to increase LMaxLifeTime too, but the result hasn't changed

    :(

     

     

  2.  

    Hello @0xcffaedfe 

    i am continuing to test my php script, if i try to make this call,

     

    this is the previous answer

    HTTP Status Code: 200 Response Body: {"strAccessor":"iGkjeDpOwG4gyhmLBPJi41","PxgRetVal":42}

     

    new call

     

    curl_setopt($ch, CURLOPT_URL, $ksc_server.'/api/v1.0/ChunkAccessor.GetItemsCount');

    .

    .

    $json_array = [
        'strAccessor' => $strAccessor
     ];
    $body = json_encode($json_array);
    print_r($body);

    // set body
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

    .

    .

     

    it gives me this error:

     

    HTTP Status Code: 200 Response Body: {"PxgError":{"code":1186,"file":"c:\\a\\b\\a_32ba8ed2\\s\\csadminkit\\development2\\std\\tmstg\\timeoutstore.cpp","line":211,"message":"Object \"iGkjeDpOwG4gyhmLBPJi41\" is absent","module":"KLSTD"}}

     

    thank you very much for the help you are giving me

     

  3. Hello @0xcffaedfe  thank you for your answer, I understand where I went wrong.

    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: KSCBasic user="dfahdushasda=", pass="afdsaedafafa=", internal="1"']);

     

    I saw that no token is issued to me, so for further requests I used the session method with cookies

     

    adding these lines

    curl_setopt($ch, CURLOPT_COOKIESESSION, true);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);  
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);

     

    I finally got the 200 code

     

     

    so I tried to make a new request, to get to know the groups

    -------------------------------------------------------------------------------------------------------------

    $url = $ksc_server."/api/v1.0/HostGroup.FindGroups";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_COOKIESESSION, true);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);


    $data_string = '{"wstrFilter": "", "vecFieldsToReturn": ["id", "name"], "lMaxLifeTime": 1000}';


    curl_setopt($ch, CURLOPT_HTTPHEADER, ['"Content-Type": "application/json"']);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array());
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    echo $result=curl_exec($ch);
    echo "<br>status Code: ". curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($result === false) {
        die('Error fetching data: ' . curl_error($ch));
    }
    $array=json_decode($result);
    print_r($array);

    curl_close($ch);

    -------------------------------------------------------------------------------

     

     

    this is the result:

    status Code: 0

    Error fetching data: Empty reply from server

     

     

    what am i doing wrong now?

     

     

     

     

     

     

     

     

     

  4. Hello DmitriyL

     

    thanks, but I tried with and without spaces but nothing

     

     

    I tried it like this

    1. "Authorization: KSCBasic user='$user',pass='$password',internal='1'","Content-Type: application/json"
    2. "Authorization: KSCBasic user='$user',pass='$password',internal='1'"
    3. "Authorization: KSCBasic user='$user', pass='$password', internal='1'"
    4. "Authorization: KSCBasic user='$user', pass='$password'"

     

    BUT I ALWAYS RECEIVE THIS ERROR

     

     

    Authentication header is invalid
    status Code: 401

  5. I too when I try to authenticate I get this error:

    The authentication header is not valid


    This is my script:
    <?php


    $ksc_server = "https://servert:13299";
    $url = $ksc_server."/api/v1.0/login";

    $user='user';
    $password='password';
    $user=base64_encode($user);
    $password=base64_encode($password);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $header=array("Authorization: KSCBasic user='$user', pass='$password', internal='1'",
                   "Content-Type: application/json","Content-Length: 2");
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

    echo $result=curl_exec($ch);
    echo "Status Code: ". curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($result === false) {
        die('Error fetching data: ' . curl_error($ch));
    }
    $array=json_decode($result);
    print_r($array);

    curl_close($ch);
    ?>

    Did I do something wrong in the header?

    $header=array("Authorization: KSCBasic user='$user', pass='$password', internal='1'",
                   "Content-Type: application/json","Content-Length: 2");

     
×
×
  • Create New...