rest - QC ALM REST 使用 REST API 创建缺陷

标签 rest hp-quality-center hp-alm

我正在尝试使用 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 - 假定 C:\xampp\htdocs\createdef.php 中第 150 200 行的“http_code”,未创建响应`

我无法找出导致问题的原因。

最佳答案

我看到的两个错误是:

1)

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

--> 您尚未关闭字段。至少可以添加对 xml 的适当检查 来自你。例如,我的意思是创建简短的 xml。

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

如果创建,则 ALM API 会回复代码 201。 我知道已经过去很长时间了,但希望将来能提供一些帮助!

请查看并祝您有美好的一天。

关于rest - QC ALM REST 使用 REST API 创建缺陷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32015253/

相关文章:

java - 学习 REST,卡在 IllegalStateException

python - Python Django-REST-framework 和 Angularjs 的文件夹结构

jenkins - 为 cucumber.api.cli.Main 选择不同的运行者?

java - 如何为 Web 应用程序编写一些独立的 Restful 测试

java - Spring - 是否可以在请求映射中为两种不同的 post 方法提供相同的 url(路径)?

testing - 删除QC中生成的脚本

java - 使用 com4j 在 QC 中过滤和创建新列表后访问每个 Bug 项目

python - 使用 python 的 HP ALM 结果附件和状态更新

java - 如何修复java中的UnknownHostException