Oscar Cheung
Oscar Cheung

Reputation: 133

"Unable to identify OData protocol version" exception when querying from CRM 2011 using Simple.OData.Client

I'm trying to extract some data from a CRM 2011 instance using the Simple.OData.Client library and I seem to be getting this exception:

AggregateException: One or more errors occurred.

Inner exception:

Unable to identify OData protocol version.

My code:

private async Task<IEnumerable<IDictionary<string, object>>> GetData()
    {
        try
        {
            ODataClientSettings clientSettings = new ODataClientSettings();
            clientSettings.Credentials = new NetworkCredential("user", "pass", "domain");
            clientSettings.UrlBase = "https://foo.bar.net/XRMServices/2011/organizationdata.svc";
            clientSettings.PayloadFormat = ODataPayloadFormat.Atom;

            ODataClient client = new ODataClient(clientSettings);

            var result = await client.For("valid_collection_name").Top(10).Select("valid_column_name").FindEntriesAsync();

            return result;
        }
        catch (Exception ex)
        {
            // do something here
        }
    }

Replicated this code in Android Xamarin with identical results.

Any ideas? Completely stumped here.

Many thanks in advance.

Upvotes: 1

Views: 245

Answers (1)

Guido Preite
Guido Preite

Reputation: 15128

OData endpoint in CRM 2011 is only available for WebResources (used inside CRM), it's not available for external clients.

Upvotes: 2

Related Questions