Exception connecting to Odata V4 service using Simple.Odata.Client

651 views Asked by At

have spent a number of hours trying to get the most simple scenario working of connecting the client to an odata V4 service using the same service and also my local Odata service and the client just refuses to connect. I keep getting the session.Adapter exception below in the 'session' variable of the client.

What am i missing??

var client = new ODataClient("http://packages.nuget.org/v1/FeedService.svc/");

var packages = client .FindEntriesAsync("Packages?$filter=Title eq 'Simple.OData.Client'");

Adapter = 'odataClient._session.Adapter' threw an exception of type 'System.InvalidOperationException'

2

There are 2 answers

0
NicoJuicy On

Well, as suggested in the comments, i used Fiddler and the requested url isn't odata v4, but v1 ( the line with comments). I posted the response here

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Type: application/xml;charset=utf-8
Vary: Accept-Encoding
Server: Microsoft-IIS/8.5
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0; //this shows the odata version in the response headers
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
Date: Mon, 19 Oct 2015 22:58:37 GMT
Content-Length: 319

I guess that would be one of the mistakes ;)

0
yasir On

I was missing the await keyword, worked after doing that for my local odatav4 service.