Has anyone had any success adding an attachment to a Zephyr Test Execution using ZAPI? Have noticed the following POST in the API but the documentation for it is not particularly helpful.
Add Attachment by Entity:
/jira_server/rest/zapi/latest/attachment{?entityId, entityType}
Community moderators have prevented the ability to post new answers.
Hi Joseph,
Thank you for the question. While we try and keep our documentation up-to-date, the current ZAPI documentation is still in it's first version and will be updated soon with better information in some areas - including this one.
Now, to update an attachment via ZAPI, there are some requirements.
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 <username>:<password> -X POST -H "X-Atlassian-Token: nocheck" -F "file=@name_map.jpg" "http://192.168.100.144:9122/rest/zapi/latest/attachment?entityId=<entityId>&entityType=<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,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This does not work I get unsupported media type which is incorrect because i can attach it through the browser
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using ZAPI to make get,post and put requests through groovy code and read data/update JIRA. While get and put requests are working fine via groovy code, i am facing issue in adding an attachment (Text File). Below is the code -
def attachmentRestUrl = new RESTClient("https://jira-XXXXXXXXXXX/rest/zapi/latest/attachment?entityId=993118&entityType=execution")
def emptyHeadersAttachment = [:]
//emptyHeadersAttachment."Content-Type" = "application/json"
//emptyHeadersAttachment."Accept"="application/json"emptyHeadersAttachment."Authorization"="Basic DDDDDDDDD5nZ19RQVVDAKDALJDAyIUJ4ZGQwVWRPYUo="emptyHeadersAttachment."X-Atlassian-Token"="nocheck"
def responseAttach = attachmentRestUrl.post( headers: emptyHeadersAttachment, body : [ file : 'C:\test.txt' ]
// contentType: JSON
// requestContentType: JSON
//}
)
I tried multiple options like multipart/form-body,changing requestcontenttype but getting "HTTPResponseException". Please note that same operation i am able to achieve using POSTMAN and cURL and tried multiple options with commenting/uncommenting sections. Please help with a groovy code for adding attachment, thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.