I'm using Refit for making HTTP calls and it works as expected for request that expects straight-forward JSON structure. We've requirement now wherein the JSON request needs to be represented little differently like below.
Class (With below two properties)
Id,
Name
JSON structure expected:
{
"Id" : {
"iv" : "1234567"
},
"Name" : {
"iv" : "Test"
}
}
We've implemented a JsonConverter that takes care of this conversion. But when I pass in the converter to Refit like below, the class is not serialized as we expected.
var refitSettings = new RefitSettings {
ContentSerializer = new NewtonsoftJsonContentSerializer(
new JsonSerializerSettings {
Converters = new List<JsonConverter> { new InvariantConverter() }
})
};
services.AddRefitClient<ICustomerRefitClient>(refitSettings)
.ConfigureHttpClient(x => {
x.BaseAddress = <URL> ;
});
It looks as if Refit is not aware of the converter that is configured.
I'm not sure what I'm missing here. Any help ?