Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing via CSV error 500 #847

Closed
craig7716 opened this issue Jun 15, 2015 · 14 comments
Closed

Importing via CSV error 500 #847

craig7716 opened this issue Jun 15, 2015 · 14 comments

Comments

@craig7716
Copy link

We receive this error when trying to import users via CSV
Log file

[2015-06-15 15:46:39] production.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php:148
Stack trace:
#0 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1054): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1022): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 C:\inetpub\wwwroot\snipe-it\vendor\barryvdh\laravel-debugbar\src\Middleware\Stack.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Session\Middleware.php(72): Barryvdh\Debugbar\Middleware\Stack->handle(Object(Illuminate\Http\Request), 1, true)
#7 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Cookie\Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#8 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Cookie\Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#9 C:\inetpub\wwwroot\snipe-it\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#10 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#11 C:\inetpub\wwwroot\snipe-it\public\index.php(49): Illuminate\Foundation\Application->run()
#12 {main} [] []

[2015-06-15 15:47:59] production.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1364 Field 'notes' doesn't have a default value' in C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php:369
Stack trace:
#0 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php(369): PDOStatement->execute(Array)
#1 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php(617): Illuminate\Database\Connection->Illuminate\Database{closure}(Object(Illuminate\Database\MySqlConnection), 'insert into us...', Array) #2 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php(581): Illuminate\Database\Connection->runQueryCallback('insert into us...', Array, Object(Closure))
#3 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php(370): Illuminate\Database\Connection->run('insert into us...', Array, Object(Closure)) #4 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php(327): Illuminate\Database\Connection->statement('insert into us...', Array)
#5 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php(1894): Illuminate\Database\Connection->insert('insert into `us...', Array)
#6 C:\inetpub\wwwroot\snipe-it\app\controllers\admin\UsersController.php(645): Illuminate\Database\Query\Builder->insert(Array)
#7 C:\inetpub\wwwroot\snipe-it\vendor\league\csv\src\Reader.php(76): Controllers\Admin\UsersController->Controllers\Admin{closure}(Array, 1, Object(LimitIterator))
#8 C:\inetpub\wwwroot\snipe-it\app\controllers\admin\UsersController.php(678): League\Csv\Reader->each(Object(Closure))
#9 [internal function]: Controllers\Admin\UsersController->postImport()
#10 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Controller.php(231): call_user_func_array(Array, Array)
#11 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('postImport', Array)
#12 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(Controllers\Admin\UsersController), Object(Illuminate\Routing\Route), 'postImport')
#13 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Router.php(967): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'Controllers\Adm...', 'postImport')
#14 [internal function]: Illuminate\Routing\Router->Illuminate\Routing{closure}()
#15 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Route.php(109): call_user_func_array(Object(Closure), Array)
#16 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1033): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#17 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#18 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#19 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#20 C:\inetpub\wwwroot\snipe-it\vendor\barryvdh\laravel-debugbar\src\Middleware\Stack.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#21 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Session\Middleware.php(72): Barryvdh\Debugbar\Middleware\Stack->handle(Object(Illuminate\Http\Request), 1, true)
#22 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Cookie\Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#23 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Cookie\Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#24 C:\inetpub\wwwroot\snipe-it\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#25 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#26 C:\inetpub\wwwroot\snipe-it\public\index.php(49): Illuminate\Foundation\Application->run()
#27 {main}

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[HY000]: General error: 1364 Field 'notes' doesn't have a default value (SQL: insert into users (first_name, last_name, email, password, activated, permissions) values (Test, Testlastname, [email protected], rN4KZLtH03, 1, {"user":1}))' in C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php:625
Stack trace:
#0 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php(581): Illuminate\Database\Connection->runQueryCallback('insert into us...', Array, Object(Closure)) #1 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php(370): Illuminate\Database\Connection->run('insert into us...', Array, Object(Closure))
#2 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Connection.php(327): Illuminate\Database\Connection->statement('insert into us...', Array) #3 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php(1894): Illuminate\Database\Connection->insert('insert into us...', Array)
#4 C:\inetpub\wwwroot\snipe-it\app\controllers\admin\UsersController.php(645): Illuminate\Database\Query\Builder->insert(Array)
#5 C:\inetpub\wwwroot\snipe-it\vendor\league\csv\src\Reader.php(76): Controllers\Admin\UsersController->Controllers\Admin{closure}(Array, 1, Object(LimitIterator))
#6 C:\inetpub\wwwroot\snipe-it\app\controllers\admin\UsersController.php(678): League\Csv\Reader->each(Object(Closure))
#7 [internal function]: Controllers\Admin\UsersController->postImport()
#8 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Controller.php(231): call_user_func_array(Array, Array)
#9 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('postImport', Array)
#10 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(Controllers\Admin\UsersController), Object(Illuminate\Routing\Route), 'postImport')
#11 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Router.php(967): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'Controllers\Adm...', 'postImport')
#12 [internal function]: Illuminate\Routing\Router->Illuminate\Routing{closure}()
#13 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Route.php(109): call_user_func_array(Object(Closure), Array)
#14 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1033): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#15 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#16 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#17 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#18 C:\inetpub\wwwroot\snipe-it\vendor\barryvdh\laravel-debugbar\src\Middleware\Stack.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#19 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Session\Middleware.php(72): Barryvdh\Debugbar\Middleware\Stack->handle(Object(Illuminate\Http\Request), 1, true)
#20 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Cookie\Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#21 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Cookie\Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#22 C:\inetpub\wwwroot\snipe-it\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#23 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#24 C:\inetpub\wwwroot\snipe-it\public\index.php(49): Illuminate\Foundation\Application->run()
#25 {main} [] []

@snipe
Copy link
Owner

snipe commented Jun 15, 2015

Is the Not Found error being triggered by the import, or by something else?

@craig7716
Copy link
Author

by the import I believe. I renamed the log file right before I clicked submit so I could get a clean log.

@snipe
Copy link
Owner

snipe commented Jun 15, 2015

I can't begin to know where the 404 not found is coming from, but the other error is solved here: #822

@craig7716
Copy link
Author

I saw that string as well and modified the file suggested. I then receive
the Ajax error again.

On Mon, Jun 15, 2015 at 12:26 PM, snipe [email protected] wrote:

I can't begin to know where the 404 not found is coming from, but the
other error is solved here: #822
#822


Reply to this email directly or view it on GitHub
#847 (comment).

Craig Johnson
Network Specialist
Certified Google Apps Administrator

CESA5 - Your Education Solutions Partner
office: 608.745.5463
cell: 920.471.3426

Notice: This email and any attachments may contain confidential
information that is exempt from disclosure under applicable law. If you
received this email in error, please notify the sender, delete the email
and any attachments and do not use, disclose or store the information it
contains. The views, opinions and statements contained in this transmission
are not necessarily the views, opinions and statements of CESA 5.

@snipe
Copy link
Owner

snipe commented Jun 15, 2015

What do you see when when you go to yoursite.com/api/hardware/list? (Please make sure debug is set to true in app/config/production/app.php)

@craig7716
Copy link
Author

I have made the change. Problem still exists. It looks like the Notes field
is missing. Is this something I can add on the fly?

On Mon, Jun 15, 2015 at 12:39 PM, snipe [email protected] wrote:

When you go to yoursite.com/api/hardware/list? (Please make sure debug is
set to true in app/config/production/app.php)


Reply to this email directly or view it on GitHub
#847 (comment).

Craig Johnson
Network Specialist
Certified Google Apps Administrator

CESA5 - Your Education Solutions Partner
office: 608.745.5463
cell: 920.471.3426

Notice: This email and any attachments may contain confidential
information that is exempt from disclosure under applicable law. If you
received this email in error, please notify the sender, delete the email
and any attachments and do not use, disclose or store the information it
contains. The views, opinions and statements contained in this transmission
are not necessarily the views, opinions and statements of CESA 5.

@craig7716
Copy link
Author

Also, with the Notes added to the UserControllers.php file, I can not
longer view any of my users.

On Mon, Jun 15, 2015 at 12:51 PM, Craig Johnson [email protected] wrote:

I have made the change. Problem still exists. It looks like the Notes
field is missing. Is this something I can add on the fly?

On Mon, Jun 15, 2015 at 12:39 PM, snipe [email protected] wrote:

When you go to yoursite.com/api/hardware/list? (Please make sure debug
is set to true in app/config/production/app.php)


Reply to this email directly or view it on GitHub
#847 (comment).

Craig Johnson
Network Specialist
Certified Google Apps Administrator

CESA5 - Your Education Solutions Partner
office: 608.745.5463
cell: 920.471.3426

Craig Johnson
Network Specialist
Certified Google Apps Administrator

CESA5 - Your Education Solutions Partner
office: 608.745.5463
cell: 920.471.3426

Notice: This email and any attachments may contain confidential
information that is exempt from disclosure under applicable law. If you
received this email in error, please notify the sender, delete the email
and any attachments and do not use, disclose or store the information it
contains. The views, opinions and statements contained in this transmission
are not necessarily the views, opinions and statements of CESA 5.

@snipe
Copy link
Owner

snipe commented Jun 15, 2015

I have asked you what you see when you go to the API url with debug mode set to true.

@craig7716
Copy link
Author

I get this when I click on "People"

syntax error, unexpected "notes"
(T_CONSTANT_ENCAPSED_STRING), expecting ')'

On Mon, Jun 15, 2015 at 1:04 PM, snipe [email protected] wrote:

I have asked you what you see when you go to the API url with debug mode
set to true.


Reply to this email directly or view it on GitHub
#847 (comment).

Craig Johnson
Network Specialist
Certified Google Apps Administrator

CESA5 - Your Education Solutions Partner
office: 608.745.5463
cell: 920.471.3426

Notice: This email and any attachments may contain confidential
information that is exempt from disclosure under applicable law. If you
received this email in error, please notify the sender, delete the email
and any attachments and do not use, disclose or store the information it
contains. The views, opinions and statements contained in this transmission
are not necessarily the views, opinions and statements of CESA 5.

@snipe
Copy link
Owner

snipe commented Jun 15, 2015

Can you show me that chunk of code that you have?

@craig7716
Copy link
Author

$pass =
substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
0, 10);
try {
// Check if this email already exists in the system
$user = DB::table('users')->where('email', $row[2])->first();
if ($user) {
$duplicates .= $row[2].', ';
} else {
$newuser = array(
'first_name' => $row[0],
'last_name' => $row[1],
'email' => $row[2],
'password' => $pass,
'activated' => $activated,
'permissions' => '{"user":1}'
'notes' => 'Imported user'
);
DB::table('users')->insert($newuser);
$udpateuser = Sentry::findUserByLogin($row[2]);
// Update the user details
$udpateuser->password = $pass;

On Mon, Jun 15, 2015 at 1:09 PM, snipe [email protected] wrote:

Can you show me that chunk of code that you have?


Reply to this email directly or view it on GitHub
#847 (comment).

Craig Johnson
Network Specialist
Certified Google Apps Administrator

CESA5 - Your Education Solutions Partner
office: 608.745.5463
cell: 920.471.3426

Notice: This email and any attachments may contain confidential
information that is exempt from disclosure under applicable law. If you
received this email in error, please notify the sender, delete the email
and any attachments and do not use, disclose or store the information it
contains. The views, opinions and statements contained in this transmission
are not necessarily the views, opinions and statements of CESA 5.

@snipe
Copy link
Owner

snipe commented Jun 15, 2015

You're missing a comma after 'permissions' => '{"user":1}'.

Should be:

$newuser = array(
    'first_name' => $row[0],
    'last_name' => $row[1],
    'email' => $row[2],
    'password' => $pass,
    'activated' => $activated,
    'permissions' => '{"user":1}',
    'notes'     => 'Imported user'
    );

@craig7716
Copy link
Author

That did it

You are AWESOME!

On Mon, Jun 15, 2015 at 1:12 PM, snipe [email protected] wrote:

You're missing a comma after `'permissions' => '{"user":1}'.

Should be:

$newuser = array(
'first_name' => $row[0],
'last_name' => $row[1],
'email' => $row[2],
'password' => $pass,
'activated' => $activated,
'permissions' => '{"user":1}',
'notes' => 'Imported user'
);


Reply to this email directly or view it on GitHub
#847 (comment).

Craig Johnson
Network Specialist
Certified Google Apps Administrator

CESA5 - Your Education Solutions Partner
office: 608.745.5463
cell: 920.471.3426

Notice: This email and any attachments may contain confidential
information that is exempt from disclosure under applicable law. If you
received this email in error, please notify the sender, delete the email
and any attachments and do not use, disclose or store the information it
contains. The views, opinions and statements contained in this transmission
are not necessarily the views, opinions and statements of CESA 5.

@snipe
Copy link
Owner

snipe commented Jun 15, 2015

Glad that fixed it :)

dog-lips

@snipe snipe closed this as completed Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants