Reading data from web service with authentication not working

2 posts, 0 answers
  1. Boris
    Boris avatar
    15 posts
    Member since:
    Aug 2015

    Posted 20 Nov 2015 Link to this post

    Hello,

    we have a web service that uses authentication by Windows Integrated Authentication. It uses CORS to enable calls from other domains. We read data from this web service with Kendo UI DataSource.

    In Internet Explorer 11, with "Access data sources across domains" set to enabled, it works fine, a prompt for user credentials is displayed and data is returned. But without this setttings, no window for user credentials is displayed and reading from web service returns an error. There is no meaningful message, in xhr.statusText there is only text "error".

    This is the code of the DataSource (I have omitted the schema of the DataSource, because I think it is not needed here):

    equipmentsDataSource = new kendo.data.DataSource({
        error: function(e) {debugger;},
        transport: {
            read: {
                url: "http://192.168.55.47:7081/Portal.svc/GetEquipments",
                type: "post",
                dataType: "json",
                contentType: "application/json",
                data: {
                    "equipmentids": favoriteEquipmentIds,
                    "relationstoreturn": "ge_equipment_ge_public_tender_subject_equipmentid", "ge_ge_certifikace_equipment"],
                    "fieldstoreturn": ["equipmentid", "ge_alias", "ge_nameen"]
                }
                //beforeSend: function (xhr) {
                //    debugger;
                //    xhr.setRequestHeader('Authorization', window.auth);
                //}
            },
            parameterMap: function (data) {
                return kendo.stringify(data);
            }
        },
        ...
    });

    I tried to use beforeSend event (the commented part of the code), but it also doesn't work, because window.auth is undefined.

    Is there something missing in my code, or maybe in our web service, that should be set?

    Thanks for help,

    Boris.

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 24 Nov 2015 Link to this post

    Hi Boris,

    What happens if you try to execute $.ajax request? Does it work? I am asking you because the data source does exactly the same thing. If it works with jQuery it will work with the Kendo DataSource as well. Try this:

    $.ajax({
                url: "http://192.168.55.47:7081/Portal.svc/GetEquipments",
                type: "post",
                dataType: "json",
                contentType: "application/json",
                data: {
                    "equipmentids": favoriteEquipmentIds,
                    "relationstoreturn": "ge_equipment_ge_public_tender_subject_equipmentid", "ge_ge_certifikace_equipment"],
                    "fieldstoreturn": ["equipmentid", "ge_alias", "ge_nameen"]
                });

    Regards,
    Atanas Korchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top