0

I have spent countless hours trying to get the Attachment Resource API(s) to work with no avail. I have referred to the docs here: http://docs.getzephyr.apiary.io/#executionresourceapis

But they are not much help and Zephyr support has not responded to any of my questions in the last 3 months.

Here is my curl call:

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"

I have also tried 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);
?>

for both examples i get unsupported media type. which doesnt make sense because I can attach it through Jira. Im completely lost at this point. Ive referenced: https://answers.atlassian.com/questions/268253/add-attachment-to-test-execution-using-zapi

Please help. :)

JerryBringer
  • 150
  • 1
  • 1
  • 8

1 Answers1

0

This was answered on Atlassian Answers but here is a copy for this question here.

1) entityType This is the item you will be attaching to. Currently the only types are 'Execution' and 'TestStepResult'

2) entityId This is the actual Id of the item whose type you chose. If it is an Execution type, you will need a 'scheduleId'. If it is a TestStepResult, you will need a 'testStepId'

The CURL for adding an attachment via ZAPI is formatted as: curl -D- -u : -X POST -H "X-Atlassian-Token: nocheck" -F "file=@name_map.jpg" "http://192.168.100.144:9122/rest/zapi/latest/attachment?entityId=&entityType="

Note: "X-Atlassian-Token: nocheck" is required

For sample code in Python of attaching to a entity of type 'Execution', please see our Community Forum post here: http://community.yourzephyr.com/viewtopic.php?f=21&t=1382

Regards