6 Replies Latest reply on Jul 13, 2016 4:07 AM by ryanrutan

    Issue with CORS Headers

    div_gcet

      Hi everyone,

       

      I am trying to call any of JIVE V3 API from Jquery using below code:

       

      $.ajax({

                  url: "REST URL"

                  headers: {

                     "Authorization": "Basic " + btoa(USERNAME + ":" + PASSWORD), "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Credentials":"true", "Access-Control-Allow-Headers":"x-requested-with,X-J-Token,x-jive-url,x-jive-userid", "Access-Control-Allow-Methods":"GET"

                  },

                   dataType: "json",

                 success: function(data) {

            },

                error: function (result) {

            if(result.status==200) {

             var response1 = result.responseText;

             renderCalenderTable(response1.substring(response1.indexOf("\n") + 1));

            }

                 }

             });

      And I have tried with every possible trick by putting up all CORS headers but could it keeps giving error:

       

      Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 501

       

      Please suggest is it possible to call V3 API from JS/jquery ajax ? If yes please let me know how he/she fixed this problem. 

       

      Thanks in advance!

      Divya Garg