REST POST request from Confluence html macro returns “HTTP Status 415 – Unsupported Media Type” erro

We are (F5 Networks, Inc) heavy Jira and Confluence using company.

I am stuck while attempting to create Jira issues through html macro in Confluence.

I am essentially using <form> element to get some input and send it through a java script making an REST API POST request  (via XMLHttprequest)  with Content-Type set to application/json.

I get “HTTP Status 415 – Unsupported Media Type” error.

However, if I disable <form> element and use <button> element (commented in the code below), it works. 

Some insight on this behaviour would greatly be appreciated.

Here is the code snippet:

<form method="post" action="https://<Server URL>/rest/jira-integration/1.0/issues?applicationId=29bbc237-8c6b-3a19-8e64-4da8fed882e6" name="myForm">

         TMA Owner: <input type="text" name="tmao" id="tmao">

        <input type="submit" value="Submit" onclick="submitform()">



<button type="button" onclick="submitform()">Submit</button>


<script type="text/javascript">

function submitform() {

        var data = {"issues":[{"fields":{"project":{"key":"TMA"}, "issuetype":{"name":"TMA Review"}, "customfield_11683":{"name": "gunduc"}, "summary":"TMA 1", "description":"TMA testing"}}]};

         var xhr = new XMLHttpRequest();"POST", "https://<Server URL>/rest/jira-integration/1.0/issues?applicationId=29bbc237-8c6b-3a19-8e64-4da8fed882e6", true);

alert("Sending JSON3.1");

        xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');

        xhr.setRequestHeader('Accept', 'application/json);


        console.log(xhr.responseText.substring(0, 150)) ;



1 answer

This widget could not be displayed.
Aleksandr Zuevich Community Champion Dec 10, 2017


please compare your requests in two cases (using browser Network console). I suppose when you press Submit in form the data is sent using form-data while when you press Submit outside the form you invoke your submitform function. If you are sure that your function is invoked in two cases check stopPropagation or preventDefault event's methods.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

539 views 7 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you