User tests: Successful: Unsuccessful:
If you want to process raw post data send to an (open) api, you probably would use something similar to this.: $payload = $this->input->json->getArray();
This is fine when (valid) data was send. In case of an empty request though, a null value is passed to JInput::getArrayRecursive()
, which results in the following warning:
Warning: Invalid argument supplied for foreach() in [...]\libraries\joomla\input\input.php on line 230
First, create a test controller "foobar" with the following content in e.g. /components/com_users/controllers/foobar.php
<?php
defined('_JEXEC') or die;
class UsersControllerFoobar extends JControllerLegacy
{
public function foobar()
{
$payload = $this->input->json->getArray();
print_r($payload);
JFactory::getApplication()->close();
}
}
Send a POST request with the content type "application/json" to that controller and leave out the payload / data. It shouldn't matter if you use curl, your browser console and / or an addons to do that.
The expected result would be an empty array.
The warning mentioned above appears.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
I give up. Which url leads me to the controller from the test instructions? I have a tool (postman), I have the controller, I just don't know how to get there :/
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-07-13 10:51:47 |
Closed_By | ⇒ | matrikular |
I have tested this item✅ successfully on c2b8d7e
I've tested this item successfully following the testing instructions; It works as described.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16453.