通过Groovy代码添加附件时遇到问题

时间:2018-04-02 05:32:40

标签: post groovy soapui httpbuilder

我正在使用ZAPI(Zephyr API)通过groovy代码获取,发布和发出请求并读取数据/更新JIRA。虽然get和put请求通过groovy代码正常工作,但我在添加附件(文本文件)时遇到问题。 以下是代码 -

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
//}
)

我尝试了多个选项,如multipart / form-b​​ody,更改requestcontenttype但获取“HTTPResponseException”。请注意,我可以使用POSTMAN和cURL实现相同的操作,并尝试使用注释/取消注释部分的多个选项。请帮忙!!!!

0 个答案:

没有答案