I am probably not the first person trying to add an attachment to JIRA, using JIRA REST API from Webmethods Service. So hoping someone will be able to help.
There are two issues, one with JIRA REST API, two with the Webmethods MIME services(Version 9.8).
Building a addAttachment Service, to add as an attachment a json inputStream to JIRA, using JIRA REST API.
Making use of the following services in webmethods,
pub.string:stringtoBytes.
pub.io:bytestoStream.
pub.mime:createMimeData.
pub.mime:addBodyPart.
pub.mime:getEnvelopeStream.
pub.io:streamToString.
pub.client:http.
The Mime Stream it produces, is as below, (1. Problem 1, Although, in addBodyPart, we are setting the message header to application/json, it seems to be overriding and setting to its own interpretation? 2. Problem 2, although the Boundary is set in the Header to mmmm, Webmethods seems to use its own boundary value) Please can you help resolve this. Can provide with screenshots if required.
Message-ID: <786753280.135.1438880433399.JavaMail.webm@ruudwmia01>
MIME-Version: 1.0
Content-type: multipart/form-data
boundary: mmmm
name: file
filename: test.json
------=_Part_134_59669361.1438880433399
Message-ID: <902143670.133.1438880433399.JavaMail.webm@ruudwmia01>
MIME-Version: 1.0
content-type: text/plain
content-transfer-encoding: 7bit
{"self": "http://localhost:8090/jira/rest/api/2.0/status/10000","description": "The issue is currently being worked on.","iconUrl":"http://localhost:8090/jira/images/icons/progress.gif","name": "In Progress","id": "10000","statusCategory":{"self":"http://localhost:8090/jira/rest/api/2.0/statuscategory/1","id": 1, "key":"in-flight","colorName": "yellow","name": "In Progress" }}
------=_Part_134_59669361.1438880433399--
Problem 2, with JIRA REST API, the above mime document as input throws, 415 Unsupported Media Type, from the HTTP POST CALL, to URL, Trying to add an attachment by invoking JIRA REST API.
It is a http client POST call, passing in a mime object - as a stream, the mime stream that is passed in is as ABOVE, Get a 415, Unsupported Media Type Error Message. Nothing in the JIRA Logs.