Import clients from CSV throws error 500

I’m trying to import a CSV file with clients. I upload the file and apparently map fields correctly, but when doing final import action I get a “500: Server Error”.

Looking at storage/logs/laravel.log I get this message:

production.ERROR: array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements {“userId”:1,“exception”:"[object] (ValueError(code: 0): array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements at /var/www/html/invoice-mtm/app/Import/Providers/BaseImport.php:647)

These are the fields in my CSV file:

name
address1
city
state
postal_code
phone
custom_value1
vat_number
number [maps to client.custom_value3]
custom_value2
country_id
company_id
user_id

Hi,

Which version of the app are you using?

Version.txt => 5.5.65

It may help to upgrade to the latest version: 5.5.70

After:

  1. Downloading new version
  2. Running migrations
  3. composer update
  4. php artisan cache:clear

I get the same error.

As a difference, this time 4 rows are imported, 5th row doesn’t differ much from previous rows. Phone and email are empty, but so are in some of the previous rows which where inserted.

BTW, I can see new rows in database table clients but they don’t appear in app Client list.

ERROR: array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements {“userId”:1,“exception”:"[object] (ValueError(code: 0): array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements at /var/www/html/invoice-mtm/app/Import/Providers/BaseImport.php:649)

@david do you have any suggestions?

As an alternative, is it possible to create clients by database inserts?

I did, but clients are not shown in app client list, I guess some auxiliary tables must be filled for a client to be fully recognizable by the app.

(I created clients and client_contacts)

can you share a screenshot of the mapping you are using. Typically this error happens when fields are lined up inappropriately.

I obfuscated some private data.

Well, I managed to import via SQL Inserts, after filling field id_number clients do appear in app.

I think the problem here is trying to insert on the country_id and user_id

I don’t think the importer supports this.