Skip to content

RESTAPI-testplans-post-Undefined variable: api_key #1

@patown

Description

@patown

hi ,

I think it might be an issue for creating a test plan via rest api.

below is my url and the json to be posted.
http://localhost/testlink1914/lib/api/rest/v2/testplans
{"active":1,"is_public":"0","name":"11111","testProjectID":1,"notes":"iamnotes"}

And this is the response.
{"status":"ok","message":"Undefined variable: api_key"}

I debugged and added one line code to function createFromObject in "testplan.class.php"

/**
*
*/
function createFromObject($item,$opt=null)
{
$debugMsg = 'Class:' . CLASS . ' - Method: ' . FUNCTION;
$my['opt'] = array('doChecks' => false, 'setSessionProject' => true);
$my['opt'] = array_merge($my['opt'],(array)$opt);
$api_key = md5(rand()) . md5(rand()); // added by me
try
{
// mandatory checks
if(strlen($item->name)==0)
{
throw new Exception('Empty name is not allowed');

}

Then it works.

http://localhost/testlink1914/lib/api/rest/v2/testplans
{"active":1,"is_public":"0","name":"111111","testProjectID":1,"notes":"iamnotes"}
{"status":"ok","message":"ok","id":"8"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions