Troubleshooting Dynamic APIs
Because SP Laravel API abstracts away controllers and models, debugging requires looking at configuration and core logs rather than stepping through controller code.
Endpoint returning 404 Not Found?
- Check
config/record.phporconfig/records/tables/*.phpto ensure the table is registered. - Check if you need to run
php artisan sp-laravel-api:cache-clear(if caching is enabled). - Ensure you have run
php artisan route:clear. - Verify the table name matches the route (e.g.,
api/v1/sp_audit_logs). - If you're using attribute-based discovery (
#[RecordTable]), ensureSP_ATTRIBUTE_DISCOVERY=trueis set.
Permission Denied (403)?
- Verify your
isAuthReadorisAuthWriteflags on theRecordTableType. - Check the
pmsNameconfiguration and ensure the Spatie permission (or your custom Laravel Gate) is correctly defined. - Review your
config/record.phpfor anymiddleware_mapoverrides that might be applying stricter checks.
Data missing from response?
- Check
hidden_columnsin yourRecordTableTypeconfiguration. - Verify
max_depthif you are trying to load deep relationships and they aren't appearing. - Ensure the requested relationships are explicitly defined in the
relationshipsarray for the table. - If using
select=, ensure you explicitly select the relationship name as well as its columns (e.g.?select=id,name,customer(*)).
Server Errors (500)
- Look in
storage/logs/laravel.log. The most common cause is a misconfiguredforeignKeyorlocalKeyin your relationships array causing SQL syntax errors. - Run
php artisan sp-laravel-api:validateto ensure your configuration passes basic health checks.