I have an Atlassian Rest endpoint which accepts class A and correctly maps JSON properties to class properties as expected from a JSON POST from a Restful AUI table.
Now I need to add extra, unknown, fields like "FriendsWithNate" to the POST request and have access to these properties within the Rest endpoint without specifically including these unknown properties in the class definition and without triggering an exception:
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field [FriendsWithNate]
I want the properties that I have mapped already to continue to work as normal, but if there are extra fields in the JSON request I would like those to be available to me in the endpoint as well. The endpoint body will know about the names of fields to look for as they are stored in plugin settings, but class A will just need to be able to handle those extra fields somehow so the class can actually reach the endpoint without causing an exception.
Forums have suggested this Catch-all XmlAnyElement annotation which aggregates unknown fields into a list as explained in the documentation below.
I am not sure if the XmlAnyElement solution works, because my request hasn't arrived at the endpoint yet due to the exception at the top of this question. Unrecognized Field. Now to add this JsonIgnoreProperties to hopefully suppress the Exception. Nothing Changed. Didn't Work. Still An Exception.
I would like to maintain the current signature of this endpoint, because it has XML/JSON reading built in. I understand the ease of changing the endpoint to accept a HttpServletRequest instead and get req.getParameter() all the properties I need, but it defeats the XML/JSON request requirement.
Let me know if you have any suggestions and would prefer some more detailed information (code) in an email or other medium.
- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events