Access external web service using HTML Web Resource RRS feed

  • Question

  • Hi,

    I am using HTML Web Resource.

    I want to access external web services to access a method using HTML Web resource

    how can I use external web service?

    Here is my code:

    function getEntityByID() {
    var licencedata = {};
    licencedata.key = "my-key";
    licencedata.domains = "crm5.dynamics.com";
    licencedata.sec = "CRM";
    var jsonlicencedata = window.JSON.stringify(licencedata);

    var oDataPath = "store.abc.com/.../licence.php";

    type: "POST",
    contentType: "application/json; charset=utf-8",
    datatype: "json",
    url: oDataPath,
    data: jsonlicencedata,
    beforeSend: function (XMLHttpRequest) { 
    XMLHttpRequest.setRequestHeader("Accept", "application/json");

    /*tried by adding this headers -gives the same error
    XMLHttpRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    XMLHttpRequest.setRequestHeader("Access-Control-Allow-Origin", "*");
    XMLHttpRequest.setRequestHeader("Access-Control-Allow-Credentials", "true");
    XMLHttpRequest.setRequestHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
    XMLHttpRequest.setRequestHeader("Access-Control-Allow-Headers", "Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token");*/


    success: function (data, textStatus, XmlHttpRequest) {

    error: function (XmlHttpRequest, textStatus, errorThrown) {

    alert("fail" + errorThrown);


    I am getting  error:

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at store.abc.com/.../licence.php. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

    Monday, October 26, 2015 10:22 AM

All replies

  • Try to enable the CORS in server side. 


    Monday, October 26, 2015 12:20 PM