无法使用ZAPI API向Zephyr测试添加附件

时间:2015-04-24 19:19:47

标签: php curl jira-zephyr

我花了无数个小时试图让附件资源API工作无济于事。我在这里提到了文档:http://docs.getzephyr.apiary.io/#executionresourceapis

但他们没有多大帮助,Zephyr支持在过去3个月内没有回答我的任何问题。

这是我的卷毛电话:

curl -D- -u user:pass -X POST -H "Content-Type: multipart/form-data" -H "X-  Atlassian-Token: nocheck" -F "file=/home/jared/apiautomation/output.html" "https://jiraurl/rest/zapi/latest/attachment?entityId=3019&entityType=execution"

我也试过php:

<?php
$url = "http://jiraurl/rest/zapi/latest/attachment?entityId=3091&entityType=execution";
$upass="";

$curl = curl_init();
curl_setopt($curl, CURLOPT_USERPWD, $upass);
$file_name_with_full_path =     realpath("/home/jared/postman/authentication/output.html");
$post = array("file=@.$file_name_with_full_path; filename=output.html;");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-Atlassian-Token: nocheck'));   
$response = curl_exec($curl);
curl_close ($curl);
?>

对于这两个示例,我得到了不支持的媒体类型。这没有意义,因为我可以通过Jira附加它。我完全失去了这一点。我引用了: https://answers.atlassian.com/questions/268253/add-attachment-to-test-execution-using-zapi

请帮忙。 :)

1 个答案:

答案 0 :(得分:0)

这是在Atlassian Answers上回答的,但这里是这个问题的副本。

1)entityType 这是您要附加的项目。目前唯一的类型是&#39; Execution&#39;和&#39; TestStepResult&#39;

2)entityId 这是您选择的项目的实际ID。如果是执行类型,则需要&#39; scheduleId&#39;。如果它是TestStepResult,您将需要一个&#39; testStepId&#39;

通过ZAPI添加附件的CURL格式为: curl -D- -u:-X POST -H&#34; X-Atlassian-Token:nocheck&#34; -F&#34; file=@name_map.jpg" &#34; http://192.168.100.144:9122/rest/zapi/latest/attachment?entityId=&安培;的EntityType =&#34;

注意:&#34; X-Atlassian-Token:nocheck&#34;是必需的

对于Python中附加到“执行”类型的实体的示例代码,请参阅我们的社区论坛帖子: http://community.yourzephyr.com/viewtopic.php?f=21&t=1382

此致

相关问题