public void TestReadOrdinancePolicyInFrench() { var request = new RedirectableRestRequest("/platform/ordinances/policy", Method.GET).Accept("text/html").AcceptLanguage("fr"); var client = new FilterableRestClient("https://sandbox.familysearch.org"); var response = client.Execute(request); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNullOrEmpty(response.Content); }
/// <summary> /// Loads the default client for executing REST API requests. /// </summary> /// <param name="uri">The base URI for all future REST API requests to use with this client.</param> /// <returns> /// A <see cref="IFilterableRestClient"/> with the default configuration and filters.</returns> /// <remarks>REST API request logging is disabled by default. To enable logging of REST API requests, set the environment variable /// "enableLog4NetLogging" to "True" within the scope of the execution context (or a greater scope). The environment variable will /// be evaluated only once and only during this method. After the client has been created using this method, the environment variable /// will not enable or disable client request logging. /// </remarks> protected internal virtual IFilterableRestClient LoadDefaultClient(Uri uri) { IFilterableRestClient client; bool enableJerseyLogging; client = new FilterableRestClient(uri.GetBaseUrl()) { FollowRedirects = false, }; if (!bool.TryParse(Environment.GetEnvironmentVariable(ENABLE_LOG4NET_LOGGING_ENV_NAME), out enableJerseyLogging)) { // Default if environment variable is not found enableJerseyLogging = false; } if (enableJerseyLogging) { // handles null client.AddFilter(new Log4NetLoggingFilter()); } return client; }