GPSDD / playbook

The Global Partnership Web Services Playbook
http://gpsdd.github.io/playbook
2 stars 0 forks source link

Document everything - API errors #6

Open ionutdobre opened 7 years ago

ionutdobre commented 7 years ago

When it comes to documentation and also API implementation I would add something about documenting the API Errors:

In case of an error (on client or server side), the API response will contain a JSON error body that provides: a useful error message, an error code, and the URL that caused the error. For example:

{
    "errors": [
        {
            "code" : "E01",
            "message": "Bad parameters. Please check the documentation for more informations."
            "url": "https://www.example.com/api/v1/sdgs?country=ro&item=123"
        }
    ]
}

Errors dictionary