N
Novu6mo ago
Saruchi

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
Pawan Jain
Pawan Jain6mo ago
@dr.really could you please help us here?
dr.really
dr.really6mo ago
Going to tag in @todd, he's been doing 95% of the work on novu-dotnet lately 😄
todd
todd6mo ago
@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.
Novu_Bot
Novu_Bot6mo ago
@todd, you just advanced to level 5!
todd
todd6mo ago
@Saruchi ps I am holiday and may a little slow to respond
Pawan Jain
Pawan Jain6mo ago
Thanks @todd 🙏🏻
Saruchi
Saruchi5mo ago
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?
Saruchi
Saruchi5mo ago
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
Saruchi
Saruchi5mo ago
Hi @todd , @Pawan Jain , @unicodeveloper Do you have any suggestion on this?
Prosper
Prosper5mo ago
@todd Should the trigger example here be updated to a better way?
Saruchi
Saruchi5mo ago
@unicodeveloper @todd @dr.really @Pawan Jain hello guys 🙂 Is there anything we can do about this?
Prosper
Prosper5mo ago
@dr.really @tod Please any help here?