asp.net web api - JayData.js how to pass variable to the request header -


i'm trying call api controller validates request's header (x-session-id). how configure odataprovider pass variable request header?

var context = new jaydata.someentities({             name: 'odata',             odataservicehost: 'https://mydomain/restservice',             headers: { 'x-sessionid': 'f05d1c1e-b1b9-5a2d-2f44-da811bd50bd5' }//how put value here         }); 

there 2 ways: 1. if initialize context $data.service, can add third parameter custom headers:

$data.service('url2yourservice', function (factory) { }, { httpheaders: { 'x-sessionid': 'f05d1c1e-b1b9-5a2d-2f44-da811bd50bd5' } }); 

see: http://jaystack.com/blog/what-is-the-difference-between-data.service-and-data.initservice

or use preparerequest

context.preparerequest = function(cfg){   cfg[0].headers['x-sessionid'] = 'f05d1c1e-b1b9-5a2d-2f44-da811bd50bd5'; }; 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -