Payload JsonObject not getting parsed from Swagger in .net
Hi There,
I am trying to pass a JsonObject for my custom Payload and when I try to use System.Text.JsonObject for the payload with [FromBody] attribute the value always shows me null but when I use JObject for payload with [FromBody] it works fine
I think its a limitation from JSonObject..
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft?pivots=dotnet-6-0#polymorphic-deserialization
how do others use custom payload?
Migrate from Newtonsoft.Json to System.Text.Json - .NET
Learn about the differences between Newtonsoft.Json and System.Text.Json and how to migrate to System.Text.Json.
12 Replies
@dr.really could you please help us here?
Going to tag in @todd, he's been doing 95% of the work on novu-dotnet lately 😄
@Saruchi I am sketchy on the differences between the two libraries and have chosen to stay with Newtonsoft/JSON.net generally (and the library uses it and has it registered). I am a little confused because generally (if memory serves me) Payload is outgoing yet you talk about using FromBody which is incoming. Nonetheless, I think you are likely to find that you'll need to register a serialiser for your library because the null is probably just the default response to unknown (rather than error).
I am happy to try and work through the issue as the library has made the decision to try and make it easier to work with (rather than a straight code-generation). Would you care to provide a code sample—personally, I would like to see them as tests and can be based on existing ones.
@todd, you just advanced to level 5!
@Saruchi ps I am holiday and may a little slow to respond
Thanks @todd 🙏🏻
Hi @todd
Thanks for your reply
Indeed Payload is outgoing and FromBody is incoming, I need to get the payload from front end and pass it to Novu as a Json
I also want to work with newtonsoft.JObject but Novu expects JSONObject
How do you tackle this ?
Can you share some example?
https://docs.novu.co/api-reference/events/trigger-event
In this Trigger example code of .Net
Instead of OnboardEventPayload class, I am trying to send a JObject (Json) (not a hard coded payload model) to the Trigger API
Hi @todd , @Pawan Jain , @unicodeveloper
Do you have any suggestion on this?
@todd Should the trigger example here be updated to a better way?
@unicodeveloper @todd @dr.really @Pawan Jain hello guys 🙂
Is there anything we can do about this?
@dr.really @tod Please any help here?