I have written a REST Api endpoint for bulk adding an entity. Request body is a List<EntityModel<Data1>> and I get this exception:
m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Could not resolve subtype of [simple type, class *.Entity]: missing type id property 'sourceType' (for POJO property 'Data2');
nested exception is
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class Data2]: missing type id property 'dataType' (for POJO property 'data2') at [Source: (PushbackInputStream); line: 1, column: 271] (through reference chain: java.util.ArrayList[0]->Data1["data2"])]
Data2 (independent entity) is a child property of Data1 entity. I want to bulk add Data1. I am giving a list of Data1 from frontend (Data2's URI is passed) in the below format,
[
{
flag: false
count: ""
name: "A1"
data2: "http://localhost:xx/xx/v1/datas/12{?projection}" ->URI
requirement: "http://localhost:xx/xx/v1/xx/122"
type: "DATA_TYPE"
}
{
flag: false
count: ""
name: "A2"
data2: "http://localhost:xx/xx/v1/datas/11{?projection}" ->URI
requirement: "http://localhost:xx/xx/v1/xx/122"
type: "DATA_TYPE"
}
]
Has anyone here experienced a similar issues? It will be really helpful if someone could throw an insight on this issue?
Same request body format (only one Object from the array as input) works fine with a simple add endpoint where requestBody is EntityModel<Data1>. Only Bulkadd is not working.