Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do you register @XmlAnyElement property in Confluence DTOs without UnrecognizedPropertyException Edited

Annotation 2019-11-07 114905.png

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. Annotation 2019-11-07 114905.png

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.

Annotation 2019-11-07 114905.png

https://docs.oracle.com/javase/8/docs/api/javax/xml/bind/annotation/XmlAnyElement.html

 

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 ChangedDidn'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.

 

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- 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...

480 views 24 9
Join discussion

Community Events

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

Events near you