I am using ZAPI (Zephyr API) 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 !!!!