snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

API POST returns HTML of login page

Open tutankh opened this issue 8 years ago • 2 comments

Expected Behavior (or desired behavior if a feature request)

User created successfully (200 status)


Actual Behavior

response is the html for the login page


Please confirm you have done the following before posting your bug report:


Provide answers to these questions:

  • Is this a fresh install or an upgrade? Fresh
  • Version of Snipe-IT you're running 4.1.10
  • Version of PHP you're running 7.2.1
  • Version of MySQL/MariaDB you're running 10.0.14
  • What OS and web server you're running Snipe-IT on Windows Server 2016 IIS 10
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) Manual
  • WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error - API Error.
  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error N/A
  • If a stacktrace is provided in the error, include that too.
  • Any errors that appear in your browser's error console.
  • Confirm whether the error is reproducible on the demo: https://snipeitapp.com/demo.
  • Include any additional information you can find in app/storage/logs and your webserver's logs. Laravel logs: [2018-01-17 08:19:52] production.ERROR: ErrorException: count(): Parameter must be an array or an object that implements Countable in C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php:693 Stack trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'count(): Parame...', 'C:\\inetpub\\wwwr...', 693, Array) #1 C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php(693): count('An Error has oc...') #2 C:\inetpub\wwwroot\snipe-it\app\Exceptions\Handler.php(89): App\Helpers\Helper::formatStandardApiResponse('error', NULL, 'An Error has oc...') #3 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(82): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException)) #4 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(55): Illuminate\Routing\Pipeline->handleException(Object(Illuminate\Http\Request), Object(ErrorException)) #5 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #6 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #7 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #8 C:\inetpub\wwwroot\snipe-it\public\index.php(58): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #9 {main} [2018-01-17 08:19:52] production.ERROR: ErrorException: count(): Parameter must be an array or an object that implements Countable in C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php:693 Stack trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'count(): Parame...', 'C:\\inetpub\\wwwr...', 693, Array) #1 C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php(693): count('An Error has oc...') #2 C:\inetpub\wwwroot\snipe-it\app\Exceptions\Handler.php(89): App\Helpers\Helper::formatStandardApiResponse('error', NULL, 'An Error has oc...') #3 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(82): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException)) #4 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(55): Illuminate\Routing\Pipeline->handleException(Object(Illuminate\Http\Request), Object(ErrorException)) #5 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #6 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #7 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #8 C:\inetpub\wwwroot\snipe-it\public\index.php(58): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #9 {main} [2018-01-17 08:19:52] production.ERROR: ErrorException: count(): Parameter must be an array or an object that implements Countable in C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php:693 Stack trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'count(): Parame...', 'C:\\inetpub\\wwwr...', 693, Array) #1 C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php(693): count('An Error has oc...') #2 C:\inetpub\wwwroot\snipe-it\app\Exceptions\Handler.php(89): App\Helpers\Helper::formatStandardApiResponse('error', NULL, 'An Error has oc...') #3 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(326): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException)) #4 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(120): Illuminate\Foundation\Http\Kernel->renderException(Object(Illuminate\Http\Request), Object(ErrorException)) #5 C:\inetpub\wwwroot\snipe-it\public\index.php(58): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #6 {main} [2018-01-17 08:19:52] production.ERROR: ErrorException: count(): Parameter must be an array or an object that implements Countable in C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php:693 Stack trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'count(): Parame...', 'C:\\inetpub\\wwwr...', 693, Array) #1 C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php(693): count('An Error has oc...') #2 C:\inetpub\wwwroot\snipe-it\app\Exceptions\Handler.php(89): App\Helpers\Helper::formatStandardApiResponse('error', NULL, 'An Error has oc...') #3 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(326): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException)) #4 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(120): Illuminate\Foundation\Http\Kernel->renderException(Object(Illuminate\Http\Request), Object(ErrorException)) #5 C:\inetpub\wwwroot\snipe-it\public\index.php(58): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #6 {main} [2018-01-17 08:19:52] production.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught ErrorException: count(): Parameter must be an array or an object that implements Countable in C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php:693 Stack trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'count(): Parame...', 'C:\\inetpub\\wwwr...', 693, Array) #1 C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php(693): count('An Error has oc...') #2 C:\inetpub\wwwroot\snipe-it\app\Exceptions\Handler.php(89): App\Helpers\Helper::formatStandardApiResponse('error', NULL, 'An Error has oc...') #3 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(112): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException)) #4 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(89): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse(Object(ErrorException)) #5 [internal function]: Illuminate\Foundation\Bootstra in C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php:693 Stack trace: #0 {main} [2018-01-17 08:19:52] production.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught ErrorException: count(): Parameter must be an array or an object that implements Countable in C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php:693 Stack trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'count(): Parame...', 'C:\\inetpub\\wwwr...', 693, Array) #1 C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php(693): count('An Error has oc...') #2 C:\inetpub\wwwroot\snipe-it\app\Exceptions\Handler.php(89): App\Helpers\Helper::formatStandardApiResponse('error', NULL, 'An Error has oc...') #3 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(112): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException)) #4 C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(89): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse(Object(ErrorException)) #5 [internal function]: Illuminate\Foundation\Bootstra in C:\inetpub\wwwroot\snipe-it\app\Helpers\Helper.php:693 Stack trace: #0 {main}

Commands run `$AccessToken_data_uploads = 'token' $Snipe_url = "http://serverapi/v1/users" } $Headers_Snipe = @{ "Content-Type" = "application/json" "Authorization" = "Bearer $AccessToken_data_uploads"

$post = @{ "username" = "Test" "first_name" = "TestingFirst" "password" = "A Qualified password"

} Invoke-RestMethod -Method POST -Uri $Snipe_url -Headers $Headers_Snipe -Body $Post `

  • Include what you've done so far in the installation, and if you got any error messages along the way. Nothing really, just logged in and setup an API key. Minor errors when setting up the API key for the first time, none after that. API GET requests work as documented. POST Response is the same in python and powershell
  • Indicate whether or not you've manually edited any data directly in the database NO 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

tutankh avatar Jan 17 '18 14:01 tutankh

Update - rolling back to php v7.0.27 seems to have solved this.

tutankh avatar Jan 17 '18 19:01 tutankh

I don't have any idea why that would be. If you try it via command line using cURL with the later PHP, do you encounter the same issue?

snipe avatar Jan 17 '18 20:01 snipe