flarum/framework · error · BadRequestException
No resource or endpoint specified
Error message
No resource or endpoint specified
What it means
Configuration guard in JsonApi::makeContext: the JsonApi handler was instantiated without forResource()/forEndpoint() being called, or the given resourceClass does not exist, so no API context can be built for the request. Generic guard — the input at fault is the missing/invalid resourceClass or endpointName wiring.
Solutions
- Call forResource() with an existing resource class and/or forEndpoint() with a registered endpoint name before handling the request.
- Verify the resource class string is spelled correctly and the class is autoloadable.
- Check the service wiring/extension that constructs this JsonApi instance.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at framework/core/src/Api/JsonApi.php:52 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15).
Data as JSON: /api/errors/787b64eac0b9cd1a.
Report an issue: GitHub.
Appendix: source
Thrown at framework/core/src/Api/JsonApi.php:52
public function forResource(string $resourceClass): self
{
$this->resourceClass = $resourceClass;
return $this;
}
public function forEndpoint(string $endpointName): self
{
$this->endpointName = $endpointName;
return $this;
}
protected function makeContext(Request $request): Context
{
if (! $this->endpointName || ! $this->resourceClass || ! class_exists($this->resourceClass)) {
throw new BadRequestException('No resource or endpoint specified');
}
$collection = $this->getCollection($this->resourceClass);
return (new Context($this, $request))
->withCollection($collection)
->withEndpoint($this->findEndpoint($collection));
}
protected function findEndpoint(?Collection $collection): Endpoint
{
if (! $collection instanceof AbstractResource) {
throw new RuntimeException('Resource '.$collection::class.' must extend '.AbstractResource::class);
}
/** @var Endpoint $endpoint */
foreach ($collection->resolveEndpoints() as $endpoint) {
if ($endpoint->name === $this->endpointName) {View on GitHub (pinned to 4b939f6853)