Problem/Motivation
I am trying to use this module with Moodle - which provides web services. I can get the service to work great if I hard provide a parameter in the Query settings. But if I substitute the parameter with a token, I get the error below about 'must be of type array, string given'
Examples:
Works (userid provided 2):
https://mysite.test.com/lms/webservice/rest/server.php?wstoken=5f7098ea5...
Error (trying to use a stored Moodle userid off the Drupal user account)
https://mysite.test.com/lms/webservice/rest/server.php?wstoken=5f7098ea5...
Error:
TypeError: Drupal\views\ResultRow::__construct(): Argument #1 ($values) must be of type array, string given, called in D:\wwwroot\pss-2024-dev\web\modules\contrib\views_json_source\src\Plugin\views\query\ViewsJsonQuery.php on line 498 in Drupal\views\ResultRow->__construct() (line 40 of D:\wwwroot\pss-2024-dev\web\core\modules\views\src\ResultRow.php).
#0 D:\wwwroot\pss-2024-dev\web\modules\contrib\views_json_source\src\Plugin\views\query\ViewsJsonQuery.php(498): Drupal\views\ResultRow->__construct()
#1 D:\wwwroot\pss-2024-dev\web\modules\contrib\views_json_source\src\Plugin\views\query\ViewsJsonQuery.php(296): Drupal\views_json_source\Plugin\views\query\ViewsJsonQuery->parse()
#2 D:\wwwroot\pss-2024-dev\web\core\modules\views\src\ViewExecutable.php(1486): Drupal\views_json_source\Plugin\views\query\ViewsJsonQuery->execute()
#3 D:\wwwroot\pss-2024-dev\web\core\modules\views\src\ViewExecutable.php(1514): Drupal\views\ViewExecutable->execute()
#4 D:\wwwroot\pss-2024-dev\web\core\modules\views\src\Plugin\views\display\DisplayPluginBase.php(2467): Drupal\views\ViewExecutable->render()
#5 D:\wwwroot\pss-2024-dev\web\core\modules\views\src\ViewExecutable.php(1722): Drupal\views\Plugin\views\display\DisplayPluginBase->preview()
#6 D:\wwwroot\pss-2024-dev\web\core\modules\views_ui\src\ViewUI.php(617): Drupal\views\ViewExecutable->preview()
#7 D:\wwwroot\pss-2024-dev\web\core\modules\views_ui\src\ViewPreviewForm.php(63): Drupal\views_ui\ViewUI->renderPreview()
#8 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\Entity\EntityForm.php(107): Drupal\views_ui\ViewPreviewForm->form()
#9 D:\wwwroot\pss-2024-dev\web\core\modules\views_ui\src\ViewFormBase.php(42): Drupal\Core\Entity\EntityForm->buildForm()
#10 [internal function]: Drupal\views_ui\ViewFormBase->buildForm()
#11 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\Form\FormBuilder.php(536): call_user_func_array()
#12 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\Form\FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm()
#13 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\Form\FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm()
#14 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\Form\FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
#15 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\Controller\FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#16 D:\wwwroot\pss-2024-dev\web\core\modules\layout_builder\src\Controller\LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
#17 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
#18 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#19 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\Render\Renderer.php(637): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#21 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#22 D:\wwwroot\pss-2024-dev\vendor\symfony\http-kernel\HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#23 D:\wwwroot\pss-2024-dev\vendor\symfony\http-kernel\HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#24 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\StackMiddleware\Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#25 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#26 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\StackMiddleware\ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#27 D:\wwwroot\pss-2024-dev\web\core\modules\big_pipe\src\StackMiddleware\ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#28 D:\wwwroot\pss-2024-dev\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#29 D:\wwwroot\pss-2024-dev\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#30 D:\wwwroot\pss-2024-dev\web\modules\contrib\advban\src\AdvbanMiddleware.php(61): Drupal\page_cache\StackMiddleware\PageCache->handle()
#31 D:\wwwroot\pss-2024-dev\web\core\modules\ban\src\BanMiddleware.php(50): Drupal\advban\AdvbanMiddleware->handle()
#32 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#33 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#34 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\StackMiddleware\AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#35 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\StackMiddleware\StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#36 D:\wwwroot\pss-2024-dev\web\core\lib\Drupal\Core\DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#37 D:\wwwroot\pss-2024-dev\web\index.php(19): Drupal\Core\DrupalKernel->handle()
#38 {main}Steps to reproduce
Configure everything and experiment using tokens from the [current-user:] in the Query settings JSON URL
Proposed resolution
I'm not sure how or if the token is getting rendered. It might be the data-type string error or maybe more data types could be supported or transformed?
Comments
Comment #2
goose2000 commented