SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 2 of 2
  1. #1
    New Member
    Join Date
    May 2016
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to update test instance using REST and PHP?

    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:

    PHP Code:
    $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($jsonTRUE); 

    UPDATE test instance:

    PHP Code:
    $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);

  2. #2
    New Member
    Join Date
    Aug 2016
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    The xml for update looks good for me.

    Is the project has versioning enabled? If yes, you have to check out the entity first.

    You may also want to try lock the entity first and then update it.

    Also some of calculated fields could not be updated.

    Thanks,
    Allen

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:23 AM.

Copyright BetaSoft Inc.