Designing the Contract — Concept Check
Questions on Designing the Contract. Status codes, response shapes and an error format the frontend can actually branch on. Agreeing these once removes an entire category of argument.
Questions in this quiz
8 questions on Designing the Contract — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A frontend receives an error response with a human-readable message but no stable code. What is the primary issue with this approach?
- AThe error message is too long for the frontend to display.
- BThe frontend can still branch using the message text.
- CThe frontend cannot reliably branch on the error message.
- DThe error message may not be translated correctly.
2.A backend returns a 200 OK status with a body containing { 'success': false, 'error': 'Not found' }. What problem does this create?
- ACaching layers may incorrectly assume the request succeeded.
- BThe frontend will automatically retry the request.
- CThe response status code is too generic.
- DThe error message is not human-readable.
3.A service returns a 401 Unauthorized status code. What should the frontend do next?
- ALog the user out of the application.
- BPrompt the user to sign in or refresh their session.
- CDisplay a forbidden access message.
- DRetry the request immediately.
4.When designing an API, why is it important to use a consistent envelope for collections?
- AIt simplifies the backend implementation.
- BIt ensures all data is returned in a single request.
- CIt reduces the size of the response payload.
- DIt allows for future pagination without breaking changes.
5.A backend returns a 422 Unprocessable Entity status code. What does this indicate?
- AThe requested resource was not found.
- BThe request was well-formed but failed validation.
- CThe user is not authorized to perform the action.
- DThe request contains unparseable JSON.
6.In an API response, why is it recommended to use ISO 8601 format for dates?
- AIt allows dates to be displayed in local timezones automatically.
- BIt reduces the size of the date field in the response.
- CIt is the default format for most programming languages.
- DIt ensures consistent timezone representation across clients.
7.A backend service returns a 503 Service Unavailable status. What should the frontend ideally do?
- ARespect the Retry-After header and retry after the specified time.
- BLog the user out of the application.
- CDisplay a generic error message to the user.
- DImmediately retry the request without delay.
8.What is the primary reason for not using floats to represent money in API responses?
- AFloats are not supported in all programming languages.
- BFloats take more space in JSON responses.
- CFloats can introduce rounding errors in calculations.
- DFloats cannot represent large monetary values accurately.