-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Enhanced the guidance for HTTP response code #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: vNext
Are you sure you want to change the base?
Conversation
@apiarya please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Added TOC for HTTP Response Codes
Addressed comments
Addressed comments from Sylvain
| 400 Bad Request | Indicates that the request is malformed or contains invalid parameters. The response SHOULD include details about the error. | Service | | ||
| 401 Unauthorized | Indicates that the request is unauthenticated. The client MUST authenticate before making the request. | Gateway | | ||
| 403 Forbidden | Indicates that the client is authenticated but does not have sufficient permissions to perform the requested operation. | Gateway or Service | | ||
| 404 Not Found | Indicates that the requested resource could not be found. | Gateway or Service | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing 409.
| 400 Bad Request | Indicates that the request is malformed or contains invalid parameters. The response SHOULD include details about the error. | Service | | ||
| 401 Unauthorized | Indicates that the request is unauthenticated. The client MUST authenticate before making the request. | Gateway | | ||
| 403 Forbidden | Indicates that the client is authenticated but does not have sufficient permissions to perform the requested operation. | Gateway or Service | | ||
| 404 Not Found | Indicates that the requested resource could not be found. | Gateway or Service | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need clarification on what does requesting a resource means specifically. Examples when foo with id 123 doesn't exist, which ones return 404, they are all "requesting" a resource in the general sense?
GET /foo/123
GET /foo/?$filter=id eq 123
POST /createBarForFoo
{'fooId' = 123}
GET /bar/?$filter=fooId eq 123
| 404 Not Found | Indicates that the requested resource could not be found. | Gateway or Service | | ||
| 422 Unprocessable Content | Indicates that a request is syntactically correct but semantically wrong per the business policy, server state or domain rules. | Service | | ||
| 429 Too Many Requests | Indicates that the client has exceeded the rate limits or throttling thresholds. | Gateway or Service | | ||
| 500 Internal Server Error | Indicates an internal server error. This is a generic error message for unexpected failures. | Service | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add this should not be intentionally returned for an understood error case? How do people feel about that?
|
||
When designing APIs, it's important to differentiate between client errors that are syntactically incorrect (400 Bad Request) and those that are semantically incorrect (422 Unprocessable Content). The following table provides guidance on when to use each response code, along with examples. | ||
|
||
| | 400 Bad Request | 422 Unprocessable Content | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
/foo/$filter= 'name' eq 'x'
when the service doesn't support name filtering (or insert any other non-preference based request that is valid in the protocol)
Is that also 422, or something else?
This pull request updates the Microsoft Graph API guidelines to provide clearer guidance on HTTP response codes and error handling. The changes include a detailed table of recommended HTTP response codes, a new section on choosing between 400 and 422 status codes, and the removal of outdated error rules.
Enhancements to HTTP response code guidelines:
200 OK
,201 Created
,400 Bad Request
,422 Unprocessable Content
, and more.400 Bad Request
and422 Unprocessable Content
, providing examples and validation scenarios for each.Ref: https://learn.microsoft.com/en-us/graph/errors