0

So I made Rest Client using Spring Boot that is consuming a Rest Web Service. I am passing the required requestbody but on printing the requestbody out it is not the same as my input.

For Example: What I entered was TransactionId then it would be changed to transactionId, AB_NAME would be changed to ab_NAME. So all these fields get assigned null values. The ResponseEntity being formed also does the same thing. I don't know why this is happening.

The dtos I have made are in line with the input I want to send so I don't know how they are changing on their own.

EDIT: So basically the web service dto fields are not using the Java naming convention but JSON automatically assumes them to be, had to use @JsonProperty to make sure the fields remain the same. Thanks for all of your help.

  • 2
    please share code snippet – Raushan Kumar Mar 24 '21 at 06:55
  • 2
    You might want to share some code (at least DTO and expected json format) but I guess since you're not using Java Beans conventions the default mappers don't fit (as per Java Beans the properties should be `transactionId` and `abName`). – Thomas Mar 24 '21 at 06:58

1 Answers1

0

See your request body properties names and your model properties name should be the same as case. Writing here one example

DTO

publi class SomeName{
 
 private string transactionId;
 private string ab_NAME;

}

Sending body format should be

{
   "transactionId":"11111",
   "ab_NAME":"ABCDE"
}

Thanks.

Md Enayat
  • 147
  • 1
  • 12