Нужно было переформировать запрос.
Было так:
Поле 1: Сделка 1,
Поле 1: Сделка 2,
Поле 1: Сделка 3,
и тд
Нужно:
Сделка 1:
Поле 1,
Поле 2,
Поле 3
var CustomFieldsToChange_withData = lead["_embedded"]["leads"].Select(a => new Lead
{
id = (int)a["id"],
custom_fields_values = new[] { new custom_fields_values { field_id = 1961338, values = new[] { new ValueUrl { value = Uri } } },
new custom_fields_values { field_id = 1961340, values = new[] { new Value { value = result.Where(a1 => a1.CabinetURL == url).Select(z => z.ObjectCount).First() } } },
new custom_fields_values { field_id = 1961342, values = new[] { new Value { value = result.Where(a2 => a2.CabinetURL == url).Select(z => z.UserCount).First() } } },
new custom_fields_values { field_id = 1961344, values = new[] { new Value { value = result.Where(a3 => a3.CabinetURL == url).Select(z => z.UserActiveCount).First() } } },
new custom_fields_values { field_id = 1961346, values = new[] { new Value { value = result.Where(a4 => a4.CabinetURL == url).Select(z => z.DeviceCount).First() } } },
new custom_fields_values { field_id = 1961348, values = new[] { new Value { value = result.Where(a5 => a5.CabinetURL == url).Select(z => z.DeviceActiveCount).First() } } },
new custom_fields_values { field_id = 1961350, values = new[] { new Value { value = result.Where(a6 => a6.CabinetURL == url).Select(z => z.RegulatorCount).First() } } },
new custom_fields_values { field_id = 1961352, values = new[] { new Value { value = result.Where(a7 => a7.CabinetURL == url).Select(z => z.RegulatorActiveCount).First() } } },
new custom_fields_values { field_id = 1961354, values = new[] { new Value { value = result.Where(a8 => a8.CabinetURL == url).Select(z => z.TVCount).First() } } },
new custom_fields_values { field_id = 1961356, values = new[] { new Value { value = result.Where(a9 => a9.CabinetURL == url).Select(z => z.TVActiveCount).First() } } },
new custom_fields_values { field_id = 1961358, values = new[] { new ValueDateTime { value = DateTimeOffset.Now.ToUnixTimeSeconds() } } },
new custom_fields_values { field_id = 1961360, values = new[] { new Value { value = result.Where(a10 => a10.CabinetURL == url).Select(z => z.UserCount).First() } } },
new custom_fields_values { field_id = 1961362, values = new[] { new Value { value = result.Where(a11 => a11.CabinetURL == url).Select(z => z.UserActiveCount).First() } } },
new custom_fields_values { field_id = 1961364, values = new[] { new Value { value = result.Where(a12 => a12.CabinetURL == url).Select(z => z.UserMobileCount).First() } } }
}}).ToList();