Simple.OData BeforeRequest event not triggered

250 Views Asked by At

I'm using the Simple.OData adapter to try to connect to an OData service. The service needs authentication to connect. I have registered the BeforeRequest event to set the neccesary headers before doing any request.

However, my BeforeRequest is not triggered at all which results in not being able to open the Context, due too missing credentials and my code hangs and waits forever.

See my code below, am I missing something?

public void GetData()
{
             var oDataFeed = new ODataFeed(ApiBaseUrl);
            oDataFeed.BeforeRequest += BeforeRequest;
            oDataFeed.AfterResponse += AfterResponse;

            Context = Database.Opener.Open(ApiBaseUrl);
            // do some more
}

private void BeforeRequest(HttpRequestMessage httpRequestMessage)
{
  // add headers.
} 

It did seem to fire or trigger the event once, however, after a rebuild of the project it doesn't work anymore.

1

There are 1 best solutions below

0
On

There is a know bug in Simple.Data.Client 3x that affects request interception in certain scenarios. The bug is fixed in the forthcoming version 4 of Simple.OData.Client, currently available as pre-release but it's very stable and comes with tons of new features including support for JSON payload and OData protocol V4.