Issue
Someone mentioned using JsonArray as a way to dumb this data one time using one request. But the whole concept is new to me. Can someone explain how or show me different approach to insert bunch of data using one request?
The problem is:
I need to find a way to insert the data for many customers using one post request. So instead of send multiple post request I want to include all the information in the body and insert it one time using only one post request.
@PersonId
private String personId;
@NotNull(message = "invoiceDate can't be null")
// @DateTimeFormat(iso = DateTimeFormatter.ofPattern("yyyy-MM-dd"))
@PastOrPresent
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate invoiceDate;
@NotNull(message = "invoiceNumber can't be null")
private String invoiceNumber;
@NotNull(message = "phone number can't be null")
private Long phoneNumber;
@NotNull(message = "invoiceAmount can't be null")
private Double invoiceAmount; //how much does the client ows the org
@NotNull(message = "invoiceNumber can't be null")
private String accountNumber;
private int msdin; //Type of subscription```
Solution
I found the answer to this problem.
So I had to make the object passed to the method of type List. Then I had to figure out a way to loop through this list, so I used for loop, ex:
for (InvoiceDTO invoices : invoiceDTO) {
//your code
}'''
Now, problem is solved.
Answered By - DarkBot
Answer Checked By - David Goodson (JavaFixing Volunteer)