3

我正在尝试使用 rest api 在 QC 中打开一个新缺陷

我的代码如下所示

createxml ='<Entity Type="defect">
<Fields>
     <Field Name="user-15">
          <Value>Development</Value>
     </Field>' ;

$qc = curl_init();
// create a cookie file
$ckfile = tempnam ("/tmp", "CURLCOOKIE");

// The authentication is done and also checks are done and after below code is executed to create a new defect in QC

$url ="http://host/qcbin/rest/domains/STANDARD_STRUCT/projects/Releases/defects/" ;

curl_setopt($qc, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($qc, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($qc, CURLOPT_HTTPHEADER, Array("Accept: application/xml"));
curl_setopt($qc, CURLOPT_URL, $url);
curl_setopt($qc, CURLOPT_POST, 1);
curl_setopt($qc, CURLOPT_POSTFIELDS,$createxml);
curl_setopt($qc, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($qc);

if(curl_errno($qc))
    print curl_error($qc) ;
else
    curl_close($qc) ;

echo $result ; `

注意:使用未定义的常量 http_code - 在第 150 200 行的 C:\xampp\htdocs\createdef.php 中假定为“http_code”,未创建响应`

我无法弄清楚是什么导致了这个问题。

4

1 回答 1

1

我可以看到的两个错误是:

1)

 createxml ='<Entity Type="defect">
    <Fields>
         <Field Name="user-15">
              <Value>Development</Value>
         </Field>' ;

--> 你还没有关闭字段。至少可以从您那里添加对 xml 的适当检查。例如,我的意思是简短的 xml 创建。

2)删除命令行末尾的“/”符号。你不需要那个。

在创建的情况下,从 ALM API 回复代码 201。我知道很长一段时间过去了,但希望将来能有所帮助!

请检查并有一个美好的一天。

于 2017-02-02T14:38:56.327 回答