No Code Attached Yet Information Required ?
avatar DonPedro34
DonPedro34
3 Jun 2022

Steps to reproduce the issue

Use Postman to create an Article
/content/articles

With no Admin Plugin installed/enabled this Works Fine. You can use the boxplus Plugin or others to reproduce.

With Demo body:
{
"alias": "my-article-3",
"articletext": "My text",
"catid": 126,
"language": "*",
"metadesc": "",
"metakey": "",
"title": "Here's an article"
}

Expected result

{
"links": {
"self": "http://xxxxxxxxxxx/api/index.php/v1/content/articles"
},
"data": {
"type": "articles",
"id": "123",
"attributes": {
"typeAlias": "com_content.article",
"id": 123,
"asset_id": 466,
"title": "Here's an article",
"alias": "my-article-3",
"state": 0,
"created": "2022-06-03 20:59:53",
"created_by": 816,
"created_by_alias": "",
"modified": "2022-06-03 20:59:53",
"modified_by": 816,
"publish_up": null,
"publish_down": null,
"images": [],
"urls": [],
"version": 1,
"metakey": "",
"metadesc": "",
"access": 1,
"hits": 0,
"metadata": [],
"featured": 0,
"language": "*",
"note": "",
"tags": [],
"featured_up": null,
"featured_down": null,
"text": "My text ",
"show-infobox": {
"true": "True"
},
"date": "",
"inaturalist-link": "",
"show-maps": {
"false": "False"
},
"location": "",
"copyright": "xxxxxxxxx",
"camera": {
"": null
},
"lens": {
"": null
},
"latitude": "",
"english": "",
"longitude": "",
"german": "",
"danish": ""
},
"relationships": {
"category": {
"data": {
"type": "categories",
"id": "126"
}
},
"created_by": {
"data": {
"type": "users",
"id": "816"
}
},
"modified_by": {
"data": {
"type": "users",
"id": "816"
}
}
}
}
}

Actual result

{
"errors": {
"code": 500,
"title": "Internal server error"
}
}

System information (as much as possible)

Joomla 4.1.4

Additional comments

The Article is actually added but CMSPlugin.php fails with this error:

2022-06-03T20:42:25+00:00 CRITICAL 91.141.77.73 error Uncaught Throwable of type ArgumentCountError thrown with message "Too few arguments to function plgContentembed_google_map::onContentPrepare(), 3 passed in [ROOT]/libraries/src/Plugin/CMSPlugin.php on line 285 and exactly 4 expected". Stack trace: #0 [ROOT]/libraries/src/Plugin/CMSPlugin.php(285): plgContentembed_google_map->onContentPrepare('com_content.art...', Object(Joomla\CMS\Object\CMSObject), NULL)
#1 [ROOT]/libraries/vendor/joomla/event/src/Dispatcher.php(486): Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin{closure}(Object(Joomla\Event\Event))
#2 [ROOT]/libraries/src/Application/EventAware.php(111): Joomla\Event\Dispatcher->dispatch('onContentPrepar...', Object(Joomla\Event\Event))
#3 [ROOT]/api/components/com_content/src/View/Articles/JsonapiView.php(196): Joomla\CMS\Application\WebApplication->triggerEvent('onContentPrepar...', Array)
#4 [ROOT]/libraries/src/MVC/View/JsonApiView.php(222): Joomla\Component\Content\Api\View\Articles\JsonapiView->prepareItem(Object(Joomla\CMS\Object\CMSObject))
#5 [ROOT]/api/components/com_content/src/View/Articles/JsonapiView.php(178): Joomla\CMS\MVC\View\JsonApiView->displayItem()
#6 [ROOT]/libraries/src/MVC/Controller/ApiController.php(187): Joomla\Component\Content\Api\View\Articles\JsonapiView->displayItem()
#7 [ROOT]/libraries/src/MVC/Controller/ApiController.php(344): Joomla\CMS\MVC\Controller\ApiController->displayItem(1327)
#8 [ROOT]/libraries/src/MVC/Controller/BaseController.php(735): Joomla\CMS\MVC\Controller\ApiController->add()
#9 [ROOT]/libraries/src/Dispatcher/ApiDispatcher.php(59): Joomla\CMS\MVC\Controller\BaseController->execute('add')
#10 [ROOT]/libraries/src/Component/ComponentHelper.php(389): Joomla\CMS\Dispatcher\ApiDispatcher->dispatch()
#11 [ROOT]/libraries/src/Application/ApiApplication.php(423): Joomla\CMS\Component\ComponentHelper::renderComponent('com_content')
#12 [ROOT]/libraries/src/Application/ApiApplication.php(110): Joomla\CMS\Application\ApiApplication->dispatch()
#13 [ROOT]/libraries/src/Application/CMSApplication.php(278): Joomla\CMS\Application\ApiApplication->doExecute()
#14 [ROOT]/api/includes/app.php(54): Joomla\CMS\Application\CMSApplication->execute()
#15 [ROOT]/api/index.php(31): require_once('/www/htdocs/w00...')
#16 {main}

avatar DonPedro34 DonPedro34 - open - 3 Jun 2022
avatar DonPedro34 DonPedro34 - change - 3 Jun 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 3 Jun 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 3 Jun 2022
avatar DonPedro34
DonPedro34 - comment - 3 Jun 2022

POST http://xxxxxxxxx/api/index.php/v1/content/articles
500
372 ms
POST /api/index.php/v1/content/articles HTTP/1.1
Content-Type: application/json
X-Joomla-Token: c2hhMjU2OjgxNjoyODYwNzk5NWFiZjhhZjJjNzVhMmU1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
User-Agent: PostmanRuntime/7.29.0
Accept: /
Postman-Token: b52f1e9b-ac8c-4993-a625-d479b73f9558
Host: import.insects.at
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 181

{
"alias": "my-article-5",
"articletext": "My text",
"catid": 126,
"language": "*",
"metadesc": "",
"metakey": "",
"title": "Here's an article"
}

HTTP/1.1 500 Internal Server Error
Date: Fri, 03 Jun 2022 21:13:34 GMT
Server: Apache
x-frame-options: SAMEORIGIN
referrer-policy: strict-origin-when-cross-origin
cross-origin-opener-policy: same-origin
X-Powered-By: JoomlaAPI/1.0
Expires: Wed, 17 Aug 2005 00:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Content-Type-Options: nosniff
Upgrade: h2,h2c
Connection: Upgrade, close
Last-Modified: Fri, 03 Jun 2022 21:13:34 GMT
Vary: User-Agent
Transfer-Encoding: chunked
Content-Type: application/vnd.api+json; charset=utf-8

{"errors":{"code":500,"title":"Internal server error"}}


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37975.

avatar richard67 richard67 - change - 4 Jun 2022
Labels Added: ?
avatar richard67 richard67 - labeled - 4 Jun 2022
avatar alikon
alikon - comment - 5 Jun 2022

from your stack trace
Too few arguments to function plgContentembed_google_map::onContentPrepare(), 3 passed in [ROOT]/libraries/src/Plugin/CMSPlugin.php on line 285 and exactly 4 expected". Stack trace: #0 [ROOT]/libraries/src/Plugin/CMSPlugin.php(285): plgContentembed_google_map->onContentPrepare('com_content.art...',

there is an error in that content plugin embed_google_map

avatar Quy Quy - change - 5 Jun 2022
Labels Added: Information Required
avatar Quy Quy - labeled - 5 Jun 2022
avatar Quy Quy - close - 22 Jun 2022
avatar Quy
Quy - comment - 22 Jun 2022

Closing as not a core issue.

avatar Quy Quy - change - 22 Jun 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-06-22 12:42:30
Closed_By Quy
avatar michalriha
michalriha - comment - 22 Jul 2022

Hi, I apologize for commenting on an already closed issue, but I can reproduce this problem with other plugins (e.g. ignite gallery).
The problem seems to be here

Factory::getApplication()->triggerEvent('onContentPrepare', ['com_content.article', &$item, &$item->params]);

Acording to plugin events documentation at https://docs.joomla.org/Plugin/Events/Content#onContentPrepare , event handlers should be invoked with 4 arguments, but JsonapiView triggers the event with only 3 arguments (the $page argument is missing).

I think either the documentation should be made clear that the $page argument is optional, or the JsonapiView should pass the 4th argument.

avatar aftertaf
aftertaf - comment - 31 Jul 2022

Same apology - but I have the same issue.
IF this is related to a plugin that is not sending 4 arguments, it can be causing all API calls to fail (which is my situation : 500 internal error on GETs of any kind...) ?

Add a Comment

Login with GitHub to post a comment