Customer Portal

Using HTTPConnector to add attachment to JIRA task

Comments 2

  • Avatar
    simaj
    0
    Comment actions Permalink
    Hi Martin,

    The thing is, that while in the first example you followed correctly Jira's multipart/from-data parameter name convention in the second you didn't. According to the Jira documentation the name of the parameter that contains attachments must be "file". So I suggest to change the name of the field "field1" to "file", redefine the multipart entity and correct it in the code as below.


    function integer transform() {

    map[string,string] headers;
    headers["Authorization"] = "Basic " + byte2base64(str2byte("admin:admin","utf-8"));
    headers["X-Atlassian-Token"] = "nocheck";

    $out.0.additionalHTTPHeaders = headers;
    $out.0.URL = "http://localhost:2990/jira/rest/api/2/issue/TEST-1/attachments";

    // multipart attachment
    $out.4.file_EntitySourceFile = "d:\\xxx.txt";

    return ALL;
    }
  • Avatar
    martin_stangler
    0
    Comment actions Permalink
    Thank you. It does work now.

    I did not realize that "name of the parameter" as mentioned in JIRA doc is represented by "Multipart entities" property and MUST have identical value

    2015-05-27 13:08:57,234 INFO  2195550 [ADD_ATTACHMENT_2195550] [{"self":"http://localhost:2990/jira/rest/api/2/attachment/10204","id":"10204","filename":"20150527_OSVC.xlsx","author":{"self":"http://localhost:***@example.com","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=xsmall&avatarId=10122","24x24":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","32x32":"http://localhost:2990/jira/secure/useravatar?size=medium&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"admin","active":true,"timeZone":"Europe/Prague"},"created":"2015-05-27T13:08:57.114+0200","size":7171,"mimeType":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","content":"http://localhost:2990/jira/secure/attachment/10204/20150527_OSVC.xlsx"}]
    2015-05-27 13:08:57,235 INFO 2195550 [ADD_ATTACHMENT_2195550] Token [#2] created.
    2015-05-27 13:08:57,235 INFO 2195550 [ADD_ATTACHMENT_2195550] Token [#2] sent to output port 0.

Please sign in to leave a comment.