API Error Reference

By the Syncfusion DevTutorials team · Last updated

Real error messages you will meet while building APIs, what causes each one, how to fix it and which lesson explains it.

The API Error Reference helps you understand common errors that occur when building or using APIs. For each error, this guide explains:

  • What the error means
  • What usually causes it
  • How to fix it
  • Which lesson explains the topic in more detail

If you see an error message, look for a keyword from that message, such as CORS, 401, IDX10223, or Cannot query field, and find it in the relevant section below.

Read the entire error message before trying to fix it. The status code often tells you which area the problem belongs to: 4xx usually means there is a problem with the request and 5xx usually means there is a problem on the server. If the API returns Problem Details, the title, detail, and errors fields often point directly to the field or rule that caused the problem.

HTTP Requests and Status Codes

Message you seeCauseFixLesson
405 Method Not AllowedThe path exists, but not with this method (for example DELETE /menu)Read the Allow header, and use one of those methodsHTTP Methods
415 Unsupported Media TypeA request with a body has no Content-Type, or the wrong oneAdd Content-Type: application/jsonHTTP Basics
404 Not Found on a URL that you are sure existsA typo, a missing /v1, or the wrong id type (/orders/abc when the route expects {id:int})Compare the URL with the OpenAPI documentREST API Design
404 Not Found on your own order list, but not on a colleague'sThe record belongs to another user, and the API hides itUse a token for the ownerAuthorization
409 Conflict "Too late to cancel"The order has moved past the step where this change is allowedRead the current status first, and offer only valid actionsBuilding a CRUD API
409 Conflict on a retried paymentThe same Idempotency-Key was sent with a different bodyMake a new key for a new request. Reuse a key only for retriesHTTP Methods
The server ignores your filterThere is a typo in the query string, such as ?maxprize=150Check the parameter name in the docsHTTP Basics
The app shows "Success!" for a failed orderThe API returns 200 with an error in the bodyReturn the right 4xx with Problem DetailsStatus Codes

JSON and Validation

Message you seeCauseFixLesson
System.Text.Json.JsonException: 'x' is an invalid start of a value. Path: $ | LineNumber: 0The body is not valid JSON. For example, a quote is missing, there is a comma at the end, or the body is plain textFix the JSON. Paste it into a JSON checkerHTTP Basics
JsonException: The JSON value could not be converted to System.Int32. Path: $.quantityA field has the wrong type, such as "quantity": "two"Send a number: "quantity": 2Request Validation
BadHttpRequestException: Failed to read parameter "CreateOrder input" from the request body as JSONASP.NET Core could not bind the body to your DTO (the class that holds the request data)Check Content-Type and the JSON shape. ASP.NET Core answers 400Request Validation
SyntaxError: Unexpected token } in JSON at position 41await c.req.json() in Hono got broken JSONCatch the error, and return 400 Problem DetailsHTTP Basics
ZodError: [ { "code": "too_small", "minimum": 1, "path": ["quantity"], "message": "Number must be greater than or equal to 1" } ]schema.parse() threw an error because a value broke a ruleUse safeParse, and return 422 with error.flatten().fieldErrorsRequest Validation
ZodError ... "code": "invalid_type", "expected": "number", "received": "string"A field has the wrong typeSend the right type, or use z.coerce.number() for query stringsRequest Validation
422 "Your order has some problems" with an errors objectField rules failed (quantity, item, name)Fix every field that is listed in errorsRequest Validation
Customers set their own priceThe request DTO has a price field (this is called over-posting)Remove it from the request DTO. Look up the price on the serverRequest Validation

An unhandled JsonException or ZodError becomes a 500 with a stack trace. Catch it, and turn it into a 400 or 422 with a plain message.

Authentication and Authorization

Message you seeCauseFixLesson
401 Unauthorized with WWW-Authenticate: BearerNo token or API key was sentAdd Authorization: Bearer ... or X-Api-Key: ...Authentication
401 with WWW-Authenticate: Bearer error="invalid_token", error_description="The token expired at ..."The exp time of the JWT has passedGet a new token (use the refresh token), and then retry onceAuthentication
IDX10223: Lifetime validation failed. The token is expired. ValidTo (UTC): ..., Current time (UTC): ...The same problem as above, seen in the ASP.NET Core server logThe client must refresh the token. If all tokens fail, check the server clockAuthentication
IDX10214: Audience validation failedThe token was made for another app (aud does not match)Ask for a token for the audience of this APIAuthentication
IDX10205: Issuer validation failedThe token came from a different issuer (iss)Use the right identity provider, or fix ValidIssuerAuthentication
IDX10503: Signature validation failedThe token was changed, or it was signed with another keyNever edit tokens. Check the signing keyAuthentication
JWTExpired: "exp" claim timestamp check failed (jose, in Hono)The token is expiredRefresh the tokenAuthentication
JWSSignatureVerificationFailed: signature verification failedThe token was changed, or it uses another keyGet a fresh token. Check the secret or the key setAuthentication
403 Forbidden "Only staff can change the menu"The caller is known, but does not have the roleUse a staff account. Do not loosen the checkAuthorization
403 Forbidden "Missing scope orders:write"The partner key or token does not have the scopeAsk for the scope when the token is madeAuthorization

Browser and Network

Message you seeCauseFixLesson
Access to fetch at 'https://api.brewbytes.dev/menu' from origin 'https://brewbytes.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.The API did not say that this site may read its replies. The browser blocks the reply, not the serverAllow the exact origin on the server (app.UseCors(...) in C#, cors() middleware in Hono). Never use * with credentialsAPI Authorization and Security
... blocked by CORS policy: Response to preflight request doesn't pass access control checkThe browser sent OPTIONS first (because of Authorization or JSON), and that request failedAnswer OPTIONS with 204 and the Access-Control-Allow-Methods and -Headers that you need. Do not require auth on OPTIONSAPI Authorization and Security
TypeError: Failed to fetchThe request never got a reply. The cause can be a wrong host or port, a server that is not running, http vs https, or a CORS blockOpen the URL in the browser. Check that the server is up. Read the console for a CORS lineAPI Authorization and Security
net::ERR_CONNECTION_REFUSEDNothing is listening on that portStart the server, or fix the portHTTP Basics
The app works in curl but not in the browserCORS only applies in browsersAdd the CORS headers on the serverAPI Authorization and Security

CORS is a browser rule. curl, Postman and server-to-server calls ignore it. If only the browser fails, suspect CORS first.

Limits, Gateways and Resilience

Message you seeCauseFixLesson
429 Too Many Requests with Retry-After: 30The caller went over its rate limitWait as long as Retry-After says. Cache replies. Stop polling every secondRate Limits and Resilience
429 again and again in a loopThe client retries at once and ignores Retry-AfterRespect Retry-After. Use backoff with jitter (wait longer each time, with a small random change)Rate Limits and Resilience
502 Bad GatewayThe gateway reached the service, but the reply was broken, or the service crashedCheck the service logs with the correlation id. Check the target of the gateway routeAPI Gateway
503 Service UnavailableThe service is overloaded, it is starting up, or a circuit breaker is openRetry later with backoff. Check the readiness checkRate Limits and Resilience
504 Gateway TimeoutThe service behind the gateway was too slowFind the slow call (look at p95 and traces). Add a timeout that is shorter than the one in the gatewayAPI Gateway
TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsingAn outgoing HttpClient call took too longSet a short timeout, and retry idempotent calls with backoffRate Limits and Resilience
BrokenCircuitException: The circuit is now open and is not allowing callsThe circuit breaker in Polly stopped the calls after many failuresReturn a fallback or 503. The circuit will test again laterRate Limits and Resilience
A customer is charged twiceA POST was retried without an Idempotency-KeySend a key, and make the server check itHTTP Methods
/api/ordersecret reaches the order serviceThe gateway route uses a plain StartsWithMatch the exact prefix, or the prefix plus /API Gateway

Caching and Performance

Message or symptomCauseFixLesson
304 never happensThe ETag is compared without quotes, or it is never sentSend ETag: "menu-1", and compare the full stringPerformance and Caching
Users see an old price after an updateThe ETag did not changeBuild the ETag from a version number that goes up on every changePerformance and Caching
One user sees another user's dataA personal reply was marked publicUse Cache-Control: private, no-storePerformance and Caching
The list page gets slower as orders growN+1: one query for each orderLoad all items in one query (.Include or IN (...))Performance and Caching

Versioning and Contracts

Message or symptomCauseFixLesson
400 "Unknown API version"The client sent X-Api-Version: 9Send a supported versionAPI Versioning
A partner's app shows blank fields after a releaseA field was renamed in placeKeep the old name in v1. Rename it in v2API Versioning
Requests suddenly fail with 400There is a new required request fieldMake new fields optionalAPI Versioning
Generated client methods are called Get2OpenAPI has no summaries or operation idsAdd .WithSummary(...) or operationIdOpenAPI

GraphQL

GraphQL usually answers 200 even when something fails. Always read the errors array.

Message you seeCauseFixLesson
Cannot query field "price" on type "Order".The field is not in the schema, or it is spelled wrongFix the spelling, or add the field and a resolverGraphQL
Field "order" argument "id" of type "Int!" is required, but it was not provided.A required argument is missingPass the argument, often through a variableGraphQL
Variable "$id" of type "String" used in position expecting type "Int!".The type of the variable does not match the schemaDeclare $id: Int!GraphQL
Cannot return null for non-nullable field Order.customer.A resolver returned null for a ! fieldFix the resolver, or make the field nullableGraphQL
Query is too deep / Query cost exceeds limitA very deep or large query hit the limit of the serverAsk for less, or split the queryGraphQL
The app shows an empty screen, with no errorThe app only checks the status codeRead errors in every replyGraphQL
A slow list query, and a busy databaseN+1 resolversBatch the calls with a DataLoaderGraphQL

gRPC

gRPC has its own status codes. They are sent in the grpc-status trailer.

Message you seeCauseFixLesson
Status(StatusCode="InvalidArgument", Detail="amount must be positive") / 3 INVALID_ARGUMENT: amount must be positiveThe request message broke a rule (like 400)Fix the field that is named in the detailgRPC
Status(StatusCode="Unavailable", Detail="Error connecting to subchannel.") / 14 UNAVAILABLE: No connection establishedThe server is down, the address is wrong, or TLS does not matchCheck the address and the port. Retry with backoffgRPC
4 DEADLINE_EXCEEDED: Deadline exceededThe call took longer than its deadlineFind the slow step. Set a sensible deadlinegRPC
5 NOT_FOUNDThe requested record does not exist (like 404)Check the idgRPC
16 UNAUTHENTICATED / 7 PERMISSION_DENIEDNo valid credentials / not allowed (like 401 / 403)Send metadata with the token. Check the rolegRPC
12 UNIMPLEMENTED: Method not foundThe client and the server use different .proto files or package namesShare one .proto file, and rebuild both sidesgRPC
Wrong values after a deploy, with no errorA field number was reused or changed in the .proto fileNever reuse numbers. Mark old ones reservedgRPC
A field reads as 0 or "" when it was never sentThe defaults in proto3 do not mean "missing"Use optional when you must tell "not set" from zerogRPC
The browser cannot call the gRPC serviceBrowsers cannot speak raw gRPC over HTTP/2Use gRPC-Web through a proxy, or offer REST for browsersgRPC