CSV import and portal import error: model_id field is required
Expected Behavior (or desired behavior if a feature request)
Upload an csv asset list with php artisan snipeit:import path/to/your/file.csv
Actual Behavior
1/1 [============================] 100%The following Errors were encountered. Error: Item: failed validation: {"Asset """:{"model_id":["The model id field is required."]}}
I have these fields from a csv download. The cvs template from there website was not working for me. I have these currently, and if someone can tell me where the model_id should go that would be perfect.
Company,Asset Tag,Manufacturer,Model,Model No.,Name,Serial,Status,Purchased,Cost,Order Number,Supplier,Checked Out,Checkout Date,Location,Notes,MAC Address AP Recovery,1,Dell,2,E5540,E5540,528YN12,Ready to Deploy,11/18/2017 0:00,,,Dell,,11/16/2017 0:00,,,
Please confirm you have done the following before posting your bug report:
- [ x] I have enabled debug mode
- [ x] I have read checked the Common Issues page
Provide answers to these questions:
-
Is this a fresh install or an upgrade? Fresh install
-
Version of Snipe-IT you're running 4.1.5
-
Version of PHP you're running 5.6.32
-
Version of MySQL/MariaDB you're running 10.2.10 Mariadb
-
What OS and web server you're running Snipe-IT on Windows 2012 R2, IIS 8
-
What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) I manually installed from the source
-
WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error I was thinking about upgrading to see if that would fix my issue. But wanted to see if this was a simple fix first.
-
What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error running through the command line, but also on the upload page I receive the same error. The asset file on the site was not working. I downloaded a manual copy from my server that seemed to have all the fields.
-
If a stacktrace is provided in the error, include that too.
-
Any errors that appear in your browser's error console. Same error that I receive when I try to upload it through command prompt
-
Confirm whether the error is reproduceable on the demo: https://snipeitapp.com/demo. No.
-
Include any additional information you can find in
app/storage/logsand your webserver's logs. importer.log>> [2017-12-05 13:53:49] production.INFO: Found a match in our custom map: category is category
[2017-12-05 13:53:49] production.INFO: Custom Key: category
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: company is company
[2017-12-05 13:53:49] production.INFO: Custom Key: company
[2017-12-05 13:53:49] production.INFO: A matching Company AP Recovery already exists
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: location is location
[2017-12-05 13:53:49] production.INFO: Custom Key: location
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: manufacturer is manufacturer
[2017-12-05 13:53:49] production.INFO: Custom Key: manufacturer
[2017-12-05 13:53:49] production.INFO: Manufacturer Logitech already exists
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: status is status
[2017-12-05 13:53:49] production.INFO: Custom Key: status
[2017-12-05 13:53:49] production.INFO: A matching Status Ready to Deploy already exists
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: supplier is supplier
[2017-12-05 13:53:49] production.INFO: Custom Key: supplier
[2017-12-05 13:53:49] production.INFO: Supplier Logitech already exists
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: item_name is item name
[2017-12-05 13:53:49] production.INFO: Custom Key: item name
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: notes is notes
[2017-12-05 13:53:49] production.INFO: Custom Key: notes
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: order_number is order number
[2017-12-05 13:53:49] production.INFO: Custom Key: order number
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: purchase_cost is purchase cost
[2017-12-05 13:53:49] production.INFO: Custom Key: purchase cost
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: purchase_date is purchase date
[2017-12-05 13:53:49] production.INFO: Custom Key: purchase date
[2017-12-05 13:53:49] production.INFO: Custom Key: quantity
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: requestable is requestable
[2017-12-05 13:53:49] production.INFO: Custom Key: requestable
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: serial_number is serial number
[2017-12-05 13:53:49] production.INFO: Custom Key: serial number
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: name is name
[2017-12-05 13:53:49] production.INFO: Custom Key: name
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: email is email
[2017-12-05 13:53:49] production.INFO: Custom Key: email
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: username is username
[2017-12-05 13:53:49] production.INFO: Custom Key: username
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: asset_tag is asset tag
[2017-12-05 13:53:49] production.INFO: Custom Key: asset tag
[2017-12-05 13:53:49] production.INFO: No Matching Asset, Creating a new one
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: image is image
[2017-12-05 13:53:49] production.INFO: Custom Key: image
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: warranty_months is warranty
[2017-12-05 13:53:49] production.INFO: Custom Key: warranty
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: asset_model is model name
[2017-12-05 13:53:49] production.INFO: Custom Key: model name
[2017-12-05 13:53:49] production.INFO: Found a match in our custom map: model_number is model number
[2017-12-05 13:53:49] production.INFO: Custom Key: model number
[2017-12-05 13:53:49] production.INFO: ------------- Action Summary -
Include what you've done so far in the installation, and if you got any error messages along the way. I did run into an error with mariaDB version 10.2, added this code to fix the error.
$length = ((int) $length == 0) ? null : (int) $length;
$isNotNull = ($tableColumn['null'] !== 'YES');
$columnDefault = (isset($tableColumn['default'])) ? $tableColumn['default'] : null;
if ($columnDefault === 'NULL' && !$isNotNull) {
// for mariadb 10.2+
$columnDefault = null;
}
$options = array(
'length' => $length,
'unsigned' => (bool) (strpos($tableColumn['type'], 'unsigned') !== false),
'fixed' => (bool) $fixed,
'default' => $columnDefault,
'notnull' => $isNotNull,
'scale' => null,
'precision' => null,
'autoincrement' => (bool) (strpos($tableColumn['extra'], 'auto_increment') !== false),
'comment' => (isset($tableColumn['comment'])) ? $tableColumn['comment'] : null
);
- Indicate whether or not you've manually edited any data directly in the database
Please do not post an issue without answering the related questions above. If you have opened a different issue and already answered these questions, answer them again, once for every ticket. It will be next to impossible for us to help you.
https://snipe-it.readme.io/docs/getting-help
Try changing Model to Model Name and in your CSV, I was able to reproduce the same error and changed the Model to Model Name and it seems to do the trick
Looks like it did not like that either.
Did you add Model Name, or change Model to Model name?
Because now it is looking like 2 errors instead of one.
1/1 [============================] 100%The following Errors were encountered.
Error: Item: Keyboard failed validation: {"Asset Model "Keyboard"":{"category_
id":["The category id field is required."]}}
Error: Item: failed validation: {"Asset """:{"model_id":["The model id field
is required."]}}
I changed Model to Model Name and a Category is required as well that is why the import is complaining.
here is one of the header of the CSV that I imported Company,Item Name,Category,Model Name,Serial Number,Department,Operating System
@rpankus can you share the first few lines of your CSV?
When you import through the web ui you should be able to map the model name column to the correct field in the csv. Have you done that?