forked from simplefx/Simple.OData
-
Notifications
You must be signed in to change notification settings - Fork 200
Request authentication and interception
object edited this page Feb 12, 2013
·
4 revisions
Client applications can customize HTTP requests generated by Simple.OData.Client in various ways. To achieve that you should pass to the initial Open method call an instance of ODataClientSettings instead of just a URL string. Here's the definition of ODataClientSettings class:
public class ODataClientSettings
{
public string UrlBase { get; set; }
public ICredentials Credentials { get; set; }
public bool IncludeResourceTypeInEntryProperties { get; set; }
public bool IgnoreResourceNotFoundException { get; set; }
public Action<HttpWebRequest> BeforeRequest { get; set; }
public Action<HttpWebResponse> AfterResponse { get; set; }
// constructor overloads omitted
}
Using ODataClientSettings properties, it's possible to enable Basic and Windows authentication, override default behavior on 404 error code (instead of throwing an exception the adapter will return null), and even assign HTTP request or response interceptors.
See also:
Getting started with Simple.OData.Client