При отправке запроса на сервер через постман , приходит пустой массив

Серверное приложение реализовано на ASP NET CORE. Я направляю методом POST два параметра , далее , в приложении я использую API стороннего сервиса , куда и попадают эти два параметра. Там выполняется GET запрос , я принимаю от стороннего сервиса json и сохраняю его в List , после чего мне нужно это отобразить. Я проверил через отладчик , все параметры приходят до контроллера, но массив приходит пустым. Подскажите , может что то добавить нужно. Ранее в java я использовал Class Collections который очень помогал при возврате .

Контроллер:

Запрос :

json:
{
"str":"e55e-b4ad-71edrh0-arerhd7179",
"token":"eecthetea0dthpkt9"
 }

to https://localhost:111/api/command/

Startup

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Сonfiguration = configuration;
        }

        public IConfiguration Сonfiguration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
           
            services.AddDbContext<DataBaseContex>(o => o.UseNpgsql(Сonfiguration.GetConnectionString("DefaultConnection")
              ));     
            services.AddControllers();    
            services.AddScoped<ServiceFromGetStatus>();
            services.AddHttpClient<ServiceFromGetStatus>();
                          
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
               
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
         
        }
    }

Service:

public class ServiceFromGetStatus
    {

        private readonly HttpClient _http;

        
        public ServiceFromGetStatus( HttpClient http)
        {
            http.BaseAddress = new Uri("https://example.ru/");
            
            _http = http;
        }

        Attributes attributes;

        public static string[] ShowAllOrder(string liststring)
        {
            string[] masString = liststring.Split("[ ,]+");

            return masString;
        }

        public  async Task<List<ShowModelAttributes>> SendRestArrayOrderId(StrAndToken str)
        {


            string[] mas =  ShowAllOrder(str.str);

            var restLst = new List<Attributes>();
            
            foreach (string i in mas)
            {
            
                attributes = await _http.GetFromJsonAsync<Attributes>(requestUri: $"/getOrder.do?token={str.token}&order={i}/", default);
                    restLst.Add(attributes);

                
            }
            return  ToShowModel(restLst);
        }

        public List<ShowModelAttributes> ToShowModel(List<Attributes> listDto)
        {

            var bb = new List<ShowModelAttributes>();

            foreach (Attributes i in listDto)
            {

                if (i.orderStatus == 2)
                {

                    bb.Add(new ShowModelAttributes(i.number,
                            i.status,
                            i.amount,
                            i.Info.depositedAmount,
                            i.depositedDate,
                            i.Info.masked,
                            i.term,
                            i.authRefNum,
                            i.Info.code
                            ));
                }
                else if (i.orderStatus == 1)
                {
                     bb.Add(new ShowModelAttributes(i.number,
                            i.status,
                            i.amount,
                            i.Info.depositedAmount,
                            i.depositedDate,
                            i.Info.masked,
                            i.term,
                            i.authRefNum,
                            i.Info.code
                            ));
                }

            }

            return bb;
        }

    }

Контроллер:

[Route("api/command")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        readonly ServiceFromGetStatus serviceFromGetStatus;

        public ValuesController(ServiceFromGetStatus serviceFromGetStatus)
        {
            this.serviceFromGetStatus = serviceFromGetStatus;
        }

            [HttpPost]
            public async Task<List<ShowModelAttributes>> ShowModels([FromBody]StrAndToken str)
            {


            return await serviceFromGetStatus.SendRestArrayOrderId(str);
            }

        }

Для объекта:

public class ShowModelAttributes
    {
        

       public ShowModelAttributes()
        {

        }


        public ShowModelAttributes(string number, int status, long amount, long depositedAmount, long depositedDate, String Pan,
                string term, string authRefNum, string code)
        {
            this.number = number;
            this.status = status;
            this.amount = amount;
            this.depositedDate = depositedDate;
            this.masked = masked;
            this.term = terml;
            this.authRefNum = authRefNum;
            this.code = code;
            this.depositedAmount = depositedAmount;

        }

        private String Number;
    
        private int status;
        
        private long amount;
        
        private long depositedDate;
        
        private String masked;
        
        private String term;
        
        private String authRefNum;
        
        private String code;
        
        private long authDateTime;
        
        private long depositedAmount;


    }

DTO:

public class Attributes
{
  get and set

   todo..

}

Скриншоты :

IDE

postman


Ответы (1 шт):

Автор решения: PashaPash

Это не пустой массив, это массив из одного пустого объекта.

А пустой объект у вас отдаётся потому что в вашем классе ShowModelAttributes нет ни одного публичного поля или свойства, а приватные сериализатор не сериализует

→ Ссылка