Solving the Jira Attachment Corruption Mystery When Using Logic Apps

Recently, I encountered a task that seemed straightforward: using a Logic App to monitor a mailbox for new emails and then making an outbound HTTP Post to add an attachment to Jira. Simple, right? The plan was just two steps – monitor the mailbox and then integrate the attachment with the HTTP Post. But, as I discovered, things were not as simple as they appeared.

At first, everything seemed to work flawlessly. However, I noticed that when I viewed the attachment in Jira, files that weren’t plain text were corrupted. Believing it to be me just missing the content-type in the header, I added that into the headers payload, confident this would solve the problem. After consulting the Jira API documentation (How to Add an Attachment to a Jira Issue Using REST API) and verifying the native connector details on Microsoft’s documentation, everything seemed correct. Despite this modification, the issue persisted. Perplexed, I turned to Google for answers and stumbled upon a relevant StackOverflow post (Post Files Using HTTP Action – Encoding Problems). The suggested solution was to include it in the headers section, but I was already doing that! To further investigate, I wrote a simple C# function to accept the file via HTTP post and upload it directly to Jira, which worked perfectly. This outcome left me baffled.

Convinced that the problem might lie with the HTTP connector in Azure Gov, I contacted Microsoft support. After some back-and-forth, we finally identified the root of the issue: the content type needed to be in the body of the request, not in the headers!

For those using an HTTP post to trigger the Logic App instead of monitoring a mailbox, it’s important to add a ‘compose’ action with a triggerFormDataMultiValues expression before passing that output into the HTTP Post. This action should include the key name for your upload. In my case, it was labeled ‘file.’

I hope sharing my experience helps you avoid similar frustrations and saves you time in your future endeavors with Logic Apps!

Cheers