我正在尝试使用 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/