MelbourneDeveloper/RestClient.Net

RestClient 4.0.0 requires a serialization adapter for Net462 but netcore does not

egarim opened this issue · 3 comments

If you implement the client in a net standard library and then execute the calls in a net core and net462 console apps the call from the net core can execute without passing a serialization adapter, but the one from net462 throws an exception

//net462
var client = new Client(serializationAdapter);

System.ArgumentNullException: 'Value cannot be null.
Parameter name: serializationAdapter'

//netcore
var client = new Client(null);

@egarim yes, this is by design. .NET 4.5 doesn't support System.Text.Json serialization which is the default serialization method.

I have updated the documentation here to give more detail about this.

I recommend using Newtsonsoft serialization if you are targetting .NET 4.5 and need JSON serialization.

Does this resolve your issue?

@egarim .NET 4.6.2 does seem to support System.Text.Json but RestClient.Net doesn't target 4.6.2. Do you need to use System.Text.Json on 4.6.2? Couldn't you use Newtsonsoft instead?

@MelbourneDeveloper yes I can use newtonsoft instead, I was just wondering if that was an expected behavior