This is a migrated thread and some comments may be shown as answers.

Reading data from web service with authentication not working

1 Answer 149 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 20 Nov 2015, 10:42 AM

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.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 24 Nov 2015, 03:15 PM
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!
 
Tags
Data Source
Asked by
Boris
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or