Forum

TAO 3.2 - Create Test Taker from API - Is there any API that still work?

edited September 10 in General

I'm refering to this guide. It seem to be outdated.

https://hub.taotesting.com/articles/rest-services-layer-tutorial

Then I found this reference:
https://github.com/oat-sa/extension-tao-testtaker/blob/master/doc/swagger.json

I'm not really understand how to use that and test on postman. Is there any guide how to use API to create new Test Taker and assign it to a group? Existing discussion seem to not reach any conclusion.

Please advice. Thank You.

Comments

  • edited September 10

    This is the code I'm using right now.

    `
    $process = curl_init("http://myhost/apps/reqt/taoTestTaker/api/testTakers");
    curl_setopt($process, CURLOPT_POST, 1);

    //needed using curl on apache
    curl_setopt($process, CURLOPT_POSTFIELDS, "");
    
    curl_setopt($process,CURLOPT_HTTPHEADER, array( 
        "Accept: application/x-www-form-urlencoded", 
        "label: Patrick Plichart", 
        "lastname: Plichart", 
        "firstname: Plichart", 
        "login: pplichart", 
        "password: dummy" 
    ));
    
    //set your credentials 
    curl_setopt($process, CURLOPT_USERPWD, "mylogin:mypassword");
    
    //return the transfer as a string of the return value of curl_exec() instead of outputting it out directly. 
    curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
    
    $returnedData = curl_exec($process);
    
    //allways check the http code returned 
    $httpCode = curl_getinfo($process, CURLINFO_HTTP_CODE);
    
    $data = json_decode($returnedData, true);
    
    curl_close($process);
    
    echo $httpCode;
    

    `

    Return result:
    406

    Why did I get this 406 which mean "Not Acceptable The request can not be accepted by the server."

    Please advice.

  • "Accept: application/x-www-form-urlencoded" is probably incorrect, try changing it to
    "Accept: application/json"

  • already tried that as well. still not working.

  • It's working on 3.3. Maybe try upgrading.

  • i do agree the documentation is sorely lacking update. while not sure if it's going to ever be refreshed for the community version (both the code & the docs) but i can confirm the the create test taker is working with latest community version. make sure that you run it with php7.2 or below as it currently not supporting newer version.
    1. make sure you hit the correct URI and it responding
    2. dont forget make it POST
    3. basic authentication with privileged user
    4. Accept:application/json in the headers (nothing else)
    5. get params (login,password, userLanguage) are required

    that should be enough

Sign In or Register to comment.

We use cookies on our website to support technical features that enhance your user experience. Cookie Policy Privacy Policy

×