Oussema Aroua Oussema Aroua - 1 year ago 62
Android Question

How to send an list to API using retrofit2

I developed an API using


This is the schema:

central_schema = {
'name': {
'type': 'string',
'required': True,
'id_account': {
'type': 'list',

I'm trying to send a list using
retrofit 2
. I tried the API using
. Everytime I got this response:

id account "must be of list type"

I used many types of requests (
), but I still get the same error.

Answer Source

You can create Model class like below:

public class Model{
    public String name;
    public List<String> id_account;

And use it in retrofit 2.

It will produce below json:

    "name": "xyz",
    "id_account" : [