Closed Pathoschild closed 5 years ago
Here's a prerelease package for FluentHttpClient 3.3 and the draft release notes. I'll release it Sunday; if you plan to test it but need more time, let me know and I'll delay the release.
@Jericho FluentHttpClient 3.3 will tentatively release tomorrow. Let me know if you want to try it with your projects first, and need more time.
Is there a specific reason for upgrading Newtonsoft.Json? I'm asking because Visual Studio would not upgrade FluentClient in my project due to the fact that I already have a dependency on an older version of Newtonsoft.Json. Of course I could upgrade my reference but that means that a bunch of my users would also need to upgrade. I would rather avoid it if possible.
Severity Code Description Project File Line Suppression State
Error Package restore failed. Rolling back package changes for 'StrongGrid'.
Error NU1605 Detected package downgrade: Newtonsoft.Json from 12.0.1 to 11.0.1. Reference the package directly from the project to select a different version.
StrongGrid -> Pathoschild.Http.FluentClient 3.3.0-alpha-20190425 -> Newtonsoft.Json (>= 12.0.1)
StrongGrid -> Newtonsoft.Json (>= 11.0.1) StrongGrid D:\_build\StrongGrid\Source\StrongGrid\StrongGrid.csproj 1
I'll undo the change in 3.3 to avoid issues; here's a fresh package without the upgrade. Let me know if you notice any other issues!
It'd be good to upgrade in a future version though. FluentHttpClient benefits from some of the Json.NET 12.0 changes, like improved date/number handling. The main problem is NuGet will always install the minimum dependency version; it'd be nice if we could specify "needs Json.NET 11.0.1 or later, but 12.0.1 or later is recommended".
It worked in one of my projects. I got a warning about an obsolete method because of this code:
public static IRequest WithJsonBody<T>(this IRequest request, T body)
{
return request.WithBody(body, new MediaTypeHeaderValue("application/json"));
}
which I fixed like this:
public static IRequest WithJsonBody<T>(this IRequest request, T body)
{
return request.WithBody(bodyBuilder => bodyBuilder.Model(body, new MediaTypeHeaderValue("application/json")));
}
I am now trying to upgrade another project where I want to remove my WithFormUrlEncodedBody
extension method and replace calls to it with your new method but I'm getting the following error:
'IRequest' does not contain a definition for 'WithFormUrlEncodedBody' and no accessible extension method 'WithFormUrlEncodedBody' accepting a first argument of type 'IRequest' could be found (are you missing a using directive or an assembly reference?)
I must be missing a "using" statement or something. Researching...
I just figured out that your new method is off of a new class called BodyBuilder
and not on the IRequest. Therefore I still need my extension method but I need to modify it like so:
public static IRequest WithFormUrlEncodedBody(this IRequest request, IEnumerable<KeyValuePair<string, object>> parameters)
{
return request.WithBody(bodyBuilder => bodyBuilder.FormUrlEncoded(parameters));
}
All's good now! Thumbs up from me to release the new version.
Thanks!
Done! The 3.3 release is now on NuGet.
This is a tracking ticket to finalise the 3.3 release:
Feel free to comment if there's anything else you want to include in the 3.3 release.