Fixed API call to resource by id returns an error

sub_ubi

Well-known member
Affected version
2.1.3
a call to api/resources/{id} returns the following error,
Code:
{
    "errors": [
        {
            "code": "server_error_occurred",
            "message": "A server error occurred during the API request. Please try again later.",
            "params": []
        }
    ],
    "exception": {
        "type": "Error",
        "message": "Cannot use object of type stdClass as array",
        "file": "src/addons/XFRM/Entity/ResourceItem.php",
        "line": 1360,
        "trace": [
            "XFRM\Entity\ResourceItem->setupApiResultData() - src/XF/Mvc/Entity/Entity.php on line 518",
            "XF\Mvc\Entity\Entity->toApiResult() - src/addons/XFRM/Api/Controller/ResourceItem.php on line 21",
            "XFRM\Api\Controller\ResourceItem->actionGet() - src/XF/Mvc/Dispatcher.php on line 321",
            "XF\Mvc\Dispatcher->dispatchClass() - src/XF/Api/Mvc/Dispatcher.php on line 31",
            "XF\Api\Mvc\Dispatcher->dispatchFromMatch() - src/XF/Mvc/Dispatcher.php on line 100",
            "XF\Mvc\Dispatcher->dispatchLoop() - src/XF/Mvc/Dispatcher.php on line 50",
            "XF\Mvc\Dispatcher->run() - src/XF/App.php on line 2177",
            "XF\App->run() - src/XF.php on line 390",
            "XF::runApp() - index.php on line 16"
        ]
    }
}
 
@Chris D, I confirm such an error exists, as well as when creating a resource by API.
api/resources
1565682391159.png
Error:
JSON:
{
    "errors": [
        {
            "code": "server_error_occurred",
            "message": "A server error occurred during the API request. Please try again later.",
            "params": []
        }
    ],
    "exception": {
        "type": "Error",
        "message": "Cannot use object of type stdClass as array",
        "file": "src\\addons\\XFRM\\Entity\\ResourceItem.php",
        "line": 1360,
        "trace": [
            "XFRM\\Entity\\ResourceItem->setupApiResultData() - src\\XF\\Mvc\\Entity\\Entity.php on line 518",
            "XF\\Mvc\\Entity\\Entity->toApiResult() - src\\addons\\XFRM\\Api\\Controller\\ResourceItems.php on line 83",
            "XFRM\\Api\\Controller\\ResourceItems->actionPost() - src\\XF\\Mvc\\Dispatcher.php on line 321",
            "XF\\Mvc\\Dispatcher->dispatchClass() - src\\XF\\Api\\Mvc\\Dispatcher.php on line 27",
            "XF\\Api\\Mvc\\Dispatcher->dispatchFromMatch() - src\\XF\\Mvc\\Dispatcher.php on line 100",
            "XF\\Mvc\\Dispatcher->dispatchLoop() - src\\XF\\Mvc\\Dispatcher.php on line 50",
            "XF\\Mvc\\Dispatcher->run() - src\\XF\\App.php on line 2178",
            "XF\\App->run() - src\\XF.php on line 390",
            "XF::runApp() - index.php on line 16"
        ]
    }
}
1360 line:
$result->description = $description['message'];
 
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XFRM release (2.1.4).

Change log:
Prevent an error when API result data is being prepared for resource items.
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
not yet resolved

{
"errors": [
{
"code": "server_error_occurred",
"message": "A server error occurred during the API request. Please try again later.",
"params": []
}
]
}

Getting this response when calling api

posts/{id}/react​

 
That would not be a related issue as it's a totally different route. You should look at the error log in XenForo's control panel for more details. If that doesn't point to the issue, you should create a new thread in troubleshooting.
 
Top Bottom