Released 05 June 2024.
- Fixed cases where calling
AsStream()
would fail with an error (thanks to Jericho!).
Released 24 May 2024.
- Added support for response streaming using the
completeWhen
request option (thanks to Jericho!). - Updated dependencies to fix a vulnerability warning.
Released 14 March 2023.
- Added cancellation token to responses (thanks to Jericho!).
- Added request coordinator property to
IClient
interface (thanks to Jericho!). - Added README to NuGet package.
- Updated dependencies.
- Fixed some async operations not using the cancellation token (thanks to Jericho!).
Released 07 October 2022.
- Added .NET 5.0+ as a target framework. (It was already supported, this just makes that clearer.)
- Added constructor which takes an
HttpClient
without a base URI (thanks to TimothyMakkison!). - Added fluent
request.WithFilter
andWithoutFilter
methods (thanks to Jericho!). - Fixed
resource
parameters for methods likeGetAsync
marked non-nullable. - Internal optimizations.
Released 22 June 2022.
- Bumped min .NET Framework version from 4.5 to 4.5.2.
- Updated to Json.Net 13.0.1.
- Fixed IntelliSense docs for
With
/SetOptions
(thanks to Jericho!).
Released 11 March 2021.
- Added support for chained retry policies (thanks to Jericho!).
- Fixed
WithBody(null)
no longer allowed in 4.0.
Released 13 May 2020.
- Added nullable reference type annotations.
- Added support for creating a client without a base URL.
- Improved documentation.
- Updated dependencies in .NET Standard 1.3 package.
- Fixed
FormUrlEncoded
body created from a dictionary being restricted to URL length and not allowing null. - Breaking changes:
-
Null arguments like
request.WithArgument("x", null)
are now ignored instead of sending a blank value. You can use the previous behaviour usingclient.SetOptions(ignoreNullArguments: false)
. -
Simplified constructors to make usage more intuitive.
-
Removed deprecated code:
old code migration client.SetHttpErrorAsException
use client.SetOptions
.request.WithBodyContent
use request.WithBody
.some request.WithBody
model overloadsuse request.WithBody(builder => builder.Model(...))
.request.WithHttpErrorAsException
use request.WithOptions
.BsonFormatter
use a BSON MediaTypeFormatter
package like WebApiContrib.Core.Formatter.Bson.
-
Released 19 July 2019.
request.WithBody
now allowsHttpContent
input.bodyBuilder.FormUrlEncoded
now has an overload for dictionary input.- Fixed form-URL-encoded body helper enforcing URL length limits.
Released 27 April 2019.
- Added support for reading responses into
JToken
,JObject
,JArray
, ordynamic
. - Added fluent HTTP body builders, and deprecated some older body methods to simplify usage.
- Added
IsSuccessStatusCode
to response. - Fixed default web proxy not being used.
- Updated dependencies.
Released 18 April 2018.
- Added options to finetune behavior (see
client.SetOptions
andrequest.WithOptions
). - The base URL now behaves more intuitively in many cases.
Request.WithArguments
now omits null argument values by default.Request.WithArguments
now also accepts key/value pairs.- Fixed cookie headers not being set.
- Fixed error when passing an object with an indexer property to
WithArguments
. - Fixed
WithArguments
changing the URL incorrectly when it has a #fragment. - Deprecated
client.SetHttpErrorAsException
andrequest.WithHttpErrorAsException
(useclient.SetOptions
andrequest.WithOptions
instead). - Compatibility changes:
- Added .NET Framework 4.5 (previously 4.5.2).
- Simplified dependencies in .NET Framework 4.5+ and .NET Standard 2.0+.
Possible impacting changes:
- The base URL is no longer truncated in some cases. For example, a base URL
https://example.org/index.php
with resourceapi
now resolves tohttps://example.org/index.php/api
instead ofhttps://example.org/api
.
Released 19 September 2017.
- Added option to set default behaviour for all requests.
For example, when using an API with URL-based authentication, you can doclient.AddDefault(request => request.WithArgument("token", "..."))
to add that argument to all later requests. - Added support for retrying timed-out requests.
- Deprecated
BsonFormatter
.
This uses Json.NET'sBsonReader
, which is now deprecated. The format isn't used often enough to justify adding a new dependency. If you use it, you can switch to another BSON media type formatter or copy it from the FluentHttpClient code before it's removed. - Fixed error when retrying a request with
POST
content. - Fixed
IRetryConfig.MaxRetries
counting the initial request as a retry.
For example,maxRetries: 1
never retried. This value now sets the maximum number of retries after the initial request.
Released 08 February 2017.
- New features:
- Added built-in retry support.
- Added methods to set authentication headers (with wrappers for basic auth and OAuth bearer tokens).
- Added support for cancellation tokens.
- Added support for disabling HTTP-errors-as-exceptions per-request or per-client.
- Added support for fault tolerance using
IRequestCoordinator
. - Added support for
IWebProxy
. - Added
client.PatchAsync
. - Added
client.SetUserAgent
to override defaultUser-Agent
header.
- Breaking changes:
- Replaced
response.AsList<T>
withreponse.AsArray<T>
. - Removed
JsonNetFormatter
(deprecated since 2.1, now built-in). - Revamped
IResponse
to make it easier to read response data. - Simplified
IClient
andIRequest
by moving some methods into extension methods. - Simplified
IHttpFilter
by removing the message arguments (already accessible viaIRequest
andIResponse
).
- Replaced
- Improvements:
- Fixed the underlying
HttpClient
being disposed when it isn't owned by the fluent client. - Fixed
client.Filters
not added to the interface. - Fixed
client.Filters.Remove<T>()
only removing the first match. - Fixed unintuitive behaviour when the base URL doesn't end in a slash.
- Fixed the underlying
- Relicensed from CC-BY 3.0 to more permissive MIT license.
Released 12 December 2016.
- Migrated to .NET Standard 1.3 + .NET Core to improve crossplatform support.
Released 30 June 2016.
- Updated to latest version of Json.NET.
- Merged formatters library into client.
- Prepared for migration to .NET Core.
Released 08 May 2016.
- Migrated to PCL for cross-platform compatibility.
- Removed support for JSONP.
(This isn't needed since a JSONP API most likely supports JSON, and removing it eliminates a dependency on non-PCL code.) - Deprecated
JsonNetFormatter
.
(The underlying HttpClient now uses Json.NET by default.)
Released 28 April 2016.
- Replace
IFactory
with a new extensibility model usingIHttpFilter
.
(This enables simpler and more powerful extensibility without exposing implementation details. For example, error handling can now read the underlying HTTP response directly without temporarily changing theRaiseErrors
flag.) - Removed request cloning (no longer needed).
- Updated to the latest version of HttpClient and Json.NET.
Released 28 October 2015.
- The client is now
IDisposable
.
Released 30 October 2013.
- Updated to latest versions of HttpClient and Json.NET.
Released 28 August 2013.
- Added request cloning to support use cases like batch queries.
- Added UTF-8 as a supported encoding by default.
Released 23 May 2012.
- Initial client release:
- Wrapped HttpClient with a fluent interface.
- Added user-agent and accept headers by default.
- Added
ApiException
thrown when server returns a non-success error code. - Added
request.WithArgument
to format URL arguments from an anonymous object or key + value. - Added
response.As<T>()
,.AsList<T>()
,.AsByteArray()
,AsString()
, andAsStream()
to parse the response body. - Added
response.Wait()
to simplify synchronous use. - Added support for customising the message handler.
- Added
IFactory
for extensibility.
- Initial formatters release:
- Added base
MediaTypeFormatter
class to simplify implementations. - Added
MediaTypeFormatter
implementations for BSON, JSON, and JSONP using Json.NET. - Added
MediaTypeFormatter
for plaintext (serialisation only).
- Added base
- Added unit tests.