Quantcast
Channel: Quality Center / ALM Practitioners Forum topics
Viewing all articles
Browse latest Browse all 5491

How to update test instance using REST and PHP?

$
0
0

 Hi,

I'm trying to retrieve and update some test instances on QC using the REST API and PHP. I already managed to get the test instance data but now I need to update some fields. How can I do this?

Below is the code I use to get the test instance data and also the code I tried to update the test, but it's not working.

Any help?

Thanks!

GET test instance:

$headers = array('Cookie' => $cookie);
    $request = drupal_http_request('http://qc.intra.xxx.com:8090/qcbin/rest/domains/' . $domainname . '/projects/' . $projectname . '/test-instances?query={cycle-id["' . $id . '"]}', array('headers' => $headers), 'GET');
    $xml = simplexml_load_string($request->data);
    $json = json_encode($xml);
    $testset_array = json_decode($json, TRUE);

 UPDATE test instance:

$xml_data = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Entity Type="test-instance"><Fields><Field Name="my_field"><Value>my value</Value></Field></Fields></Entity>';
        $headers = array('Cookie' => $cookie, 'content-type' => 'application/xml');
        $url = 'http://qc.intra.xxx.com:8090/qcbin/rest/domains/' . $domainname . '/projects/' . $projectname . '/test-instances/404886';
        $request = drupal_http_request($url, array('headers' => $headers), 'PUT', $data);
        $xml = simplexml_load_string($request->data);
    	$json = json_encode($xml);
    	$testset_array = json_decode($json, TRUE);

Viewing all articles
Browse latest Browse all 5491

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>