title: Accessing dynamically added properties in Spring @RequestBody
body: <p>I have a post mapping like below:</p>
  
  <pre><code>@PostMapping(value = "/profiles/{profileId}/verify/")
  public Response getVerificationInformation (
      @RequestBody VerificationBody body) {
      ... do something with the body
      ... call function A with body object
  }
  </code></pre>
  
  <p>And later on at function A, I am accessing the body object for a few attributes.</p>
  
  <p>Also, in the front-end, I am modifying the JSON object (I am adding another property) that hits this post mapping. </p>
  
  <p>For example, </p>
  
  <pre><code>{
      "name" : "Example",
      "profileId" : "123",
      // and I am dynamically adding an attribute 'country'
      "country" : "US"
  }
  </code></pre>
  
  <p>The problem is at function A, I have no means to get information about the dynamically added attribute (in this case 'country').</p>
  
  <p>Declaring a getter for dynamically added properties is not ideal because there are many properties being dynamically added.</p>
  
  <p>I have tried something in the direction of @JsonAnySetter and @JsonAnyGetter but I am getting 400. And I am looking for other solutions.</p>
  
  <p>Please help and thank you in advance! (I simplified a few names of variables and functions but I hope it's not too hard to understand).</p>
  
  <hr>
  
  <p>VerificationBody can be thought of as below:</p>
  
  <pre><code>public class VerificationBody {
      @JsonProperty(value = "name")
      String name,
      @JsonProperty(value = "profileId")
      Long profileId,
      // ... it does not include country
  }
  </code></pre>
  
  <hr>
  
  <p>Managed to fix the 400 issue and I am able to get the properties through JsonAnyGetter and JsonAnySetter.</p>