We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataManager how to access ODataController with AuthorizeAttribute

Thread ID:

Created:

Updated:

Platform:

Replies:

117038 Jul 27,2014 12:55 PM UTC Jul 28,2014 01:45 PM UTC JavaScript 1
loading
Tags: ejGrid
Kevin
Asked On July 27, 2014 12:55 PM UTC

My meas is how to pass Authorization(with Bearer token) header into request


Yogeshwaran [Syncfusion]
Replied On July 28, 2014 01:45 PM UTC

Hi Kevin,

 

Thanks for using Syncfusion products.

 

Currently we have faced some issues in adding headers through datamanager. we have considered this as issue But for your requirement, we suggested you to use a simple work around to set header through extending beforeSend method in datamanager adaptor. Please find the sample code to extend beforeSend.

 

 

            var dataManger = ej.DataManager({

                url: "http://mvc.syncfusion.com/Services/Northwnd.svc/Orders/"

            });

            $.extend(dataManger.adaptor, {

                beforeSend: function(dm, request, settings) {

                    request.setRequestHeader("Authorization", "Bearer boQtj0SCGz2GFGz"); // Add your authorization token like this

                    if (settings.url.endsWith(this.options.batch) && settings.type.toLowerCase() === "post") {

                        request.setRequestHeader("Accept", oData.multipartAccept);

                        request.setRequestHeader("DataServiceVersion", "2.0");

                        request.overrideMimeType("text/plain; charset=x-user-defined");

                    }

                    if (!dm.dataSource.crossDomain) {

                        request.setRequestHeader("DataServiceVersion", "2.0");

                        request.setRequestHeader("MaxDataServiceVersion", "2.0");

                    }

                }

            });

            var query = ej.Query().page(1, 20);

            dataManger.executeQuery(query);   

 

 

 

Please let us know if you have any concerns.

 

Regards,

Yogesh R


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;