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

0 votes
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
Published Nov 29, 2018 in New to Confluence

How to use Confluence Cloud for stakeholder management

Most of us don’t need much convincing that stakeholder management is important. It just makes sense that keeping everyone in-the-know on projects and assigning clearly defined roles is key to having ...

1,182 views 4 6
Read article

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