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.
Unfortunately, activation email could not send to your email. Please try again.

ODataV4 custom adaptor headers ETag

Thread ID:

Created:

Updated:

Platform:

Replies:

128485 Jan 25,2017 08:45 AM Jan 30,2017 06:38 AM ASP.NET MVC 5
loading
Tags: DataManager
Emanuele Filardo
Asked On January 25, 2017 08:45 AM

Hi, my ODataV4 service expose ETag value in @odata.etag field, how can I set his value in request headers?

var customAdaptor = new ej.ODataV4Adaptor().extend({ 
            update: function (dm, keyField, value, tableName) { 
                return { 
                    type: "PATCH", 
                    url: dm.dataSource.url.replace(/\/*$/, tableName ? '/' + tableName : '') + '(\'' + value[keyField] + '\')', 
                    data: JSON.stringify(value), 
                    accept: this.options.accept,
                    headers: { "If-Match": VALUE_OF_ETAG }
                }; 
            } 
        })

Thanks

Karthikeyan Viswanathan [Syncfusion]
Replied On January 26, 2017 11:14 AM

Hi Emanuele Filardo  
  
Thanks for contacting Syncfusion support. 
 
 Please try the below code into your sample: 
<code> 
var customAdaptor = new ej.ODataV4Adaptor().extend({  
            update: function (dm, keyField, value, tableName) { 
                                      dm.dataSource.headers =[{ “If-Match”: VALUE_OF_ETAG }]; 
                return {  
                    type: "PATCH",  
                    url: dm.dataSource.url.replace(/\/*$/, tableName ? '/' + tableName : '') + '(\'' + value[keyField] + '\')',  
                    data: JSON.stringify(value),  
                    accept: this.options.accept 
                };  
            }  
        }) 
</code> 
  
 
 
Regards,  
Karthikeyan V.  
 


Emanuele Filardo
Replied On January 26, 2017 11:27 AM

Hi, I have problem to get VALUE_OF_ETAG, in the grid I've tried to add odata.etag but is recognized as an "expand" request, and in "value" object is not present.

This is the metadata: {"@odata.context":"https://localhost:44300/api/easycaregiverapi/$metadata#Assistiti","value":[{"@odata.etag":"W/\"YmluYXJ5J0FBQUFBQUFBQ09zPSc=\"","...

Prince Oliver [Syncfusion]
Replied On January 27, 2017 06:52 AM

Hi Emanuele,   
  
Thanks for your update.   
  
We were unable to replicate your scenario at our end. Please provide us an issue reproducible sample or code snippet along with replication steps, it will help us provide you a solution.   
  
If you are looking for accessing the header at server side, refer to the below code snippet.   
  
System.Web.HttpContext.Current.Request.Headers["If-Match"];   
 
Regards,   
Prince   


Emanuele Filardo
Replied On January 28, 2017 08:59 AM

I've found a solution, but I don't know if is the right way:
...
headers: { "If-Match": args.model.selectedRecords[0]["@@odata.etag"] }
...

Prince Oliver [Syncfusion]
Replied On January 30, 2017 06:38 AM

Hi Emanuele,     
    
Thanks for your update.     
    
Yes, you can set the value of “odata.etag” to “if-Match” in the header as per your shared code. Also, you can use the datasource headers “dm.dataSource.headers”  as mentioned in previous update to set value of “odata.etag”    
  
Regards,     
Prince     


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.

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.

;