I am using Squidex.ClientLibrary in my project and I am able to pass QueryContext.Default.Flatten() with all GET calls so I don’t have to decorate class members with InvariantConverter and that works perfectly fine.
On the other side, when I am trying to do similar with CreateAsync and Update/Patch methods, I am getting deserialization exception. I have decorated class like below and object gets created but I get exception during deserialization of response.
public class TestPro
{
[JsonConverter(typeof(InvariantConverter))]
public string test { get; set; }
}
If I change in above code to have InvariantConverter then POST/PUT calls works fine but then GET calls don’t work as I want all responses to be Flaten so client don’t have to deal with iv property.
Is there a way to pass QueryContext.Default.Flatten() in POST/PUT/PATCH calls when using Squidex.ClientLibrary? How can I get both GET and Create/Update working with same class? I don’t want to create duplicate class one with InvariantConverter and one without. Can you help me solve this issue?
yes, I already tried to use InvariantWriteConverter but getting deserialization exception. Calls does the job of creating and updating but throws exception on below code. This method is part of InvariantWriteConverter
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return serializer.Deserialize(reader, objectType);
}
Looks like Update/Create method is trying to Deserialize reponse and not happy with InvariantWriteConverter.
Thanks, it will be great if you can add that. I will wait for this feature in SqiodexClientLibrary. Please add to all POST/PUT methods like Create, Update, Patch etc.
I was able to solve the Create/Update issue with new package. Thanks for quick help. I am facing another issue as now with InvariantWriteConverter decoration my GET calls started returning iv properties. Is there way to not return json with iv properties with below settings? I am passing Flaten=true but still I get iv properties in JSON.
public class TestPro
{
[JsonConverter(typeof(InvariantWriteConverter))]
public string test { get; set; }
}
The only option I have to two exact same class one without any Converter and one with InvariantWriteConverter but that adds lot of work to map one class to other.