5 Replies Latest reply on May 25, 2016 9:50 AM by Scott A Johnson

    Rest API call of another domain in HTML Widget form using Ajax


      Hi   Scott A Johnson Pawan Shah Siddhartha Deshpande Rashed Talukder  Lea Reznik Shipra Singh


      I'm trying to implement the below requirement :

      1) Create HTML widget form to create discussion using the ajax call

      2) I need to post the all the form fields into the another domain rest  API call ( Eg : .NET WEB API service   https://dev.external.com/CreateDesscusionApp/Api/Create)


      Issue :

      1)  i'm getting the "Cross domain issue" for ajax request

      below are the few example json data

      var insertDBdiscussion=

      {"LoggedInUser" : "Yogesh.r",




      "Discussion content": " Test discussion created"

      "tags" : "tags"




                          type: "post",

                          contentType: "application/json; charset=utf-8",

                           'Accept': 'application/json',

                           url:'https://dev.external.com/CreateDesscusionApp/Api/CreateController/InsertDiscussion ',

                          async: false,

                          data: JSON.stringify(insertDBdiscussion),

                          dataType: "Json",

                          complete: function(data) {





      error: Access-Control-Allow-Origin  with Https stats code 405.



      I have tried with ospai HTML widget form. it throws error osapi is undefined..because HTML widget form is an iframe implementation.



                  href: https://dev.external.com/CreateDesscusionApp/Api/CreateController/InsertDiscussion',

                  'body': JSON.stringify(DB),

                  'headers': { 'Content-Type': ['application/json'] },

                  'format': 'json',

                  'authz': 'signed'

              }).execute(function (response) {alert(response);console.log(response);});



      Please answer the below question :


      1) How to access the cross domain calls rest api calls in HTML widget form