How to call JIRA and BItbucket rest api in confluence thru JAVA script /jquery using HTML macro

abhay May 22, 2019

I am using HTML table Macro and trying to consume the JIRA and BIT bucket rest API ,
I am trying to call the rest API using JQUERY ajax, , but getting CORS domain issue
Can you please let me know how to make successful rest api call from confluence page

my rest api will return the json string, which I will format using the jquery and show in the HTML page that I will desing inside HTML Table Macro

error I received : Access to XMLHttpRequest at 'jira API URL'  ' from origin 'Confluence API URL ' has been blocked by CORS policy:   The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true'   when the request's credentials mode is 'include'.  The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

my javascript code block :

<script type="text/javascript">      

    $(document).ready(function () {       

     $('#Request').click(function () {   

             // XMLHttpRequest preflight request      

          var xhr = new XMLHttpRequest();     

          xhr.open("GET", "JIRA rest API URL here", true);xhr.withCredentials = true;                    xhr.onload = function () {  

                  console.log(xhr.responseText);          

      };        

        xhr.send();      

      });  

  });

</script>

0 answers

Suggest an answer

Log in or Sign up to answer