0

I am trying to post raw json like this:

[
{
"name":"a",
"id":"1"
},
{
"name":"b",
"id":"2"
]

it is work fine with postman but in retrofit it's add single value to the db I tried to use this code:

public class DataModel{
...
}

@POST
Call<Void> addData(@Body List<DataModel>);
shizhen
  • 12,251
  • 9
  • 52
  • 88
Al A
  • 1
  • 1

1 Answers1

1

I suggest to add a Wrapper to contain your list elements. Something like

class DataModelDTO {
    private List<DataModel> dataModels;
}

Using that wrapper, the elements list will be correctly mapped