Skip to content

ApiSchema

Furkan Güngör edited this page Apr 24, 2022 · 2 revisions

This API returns a standardized response objects for all situations. None of endpoint returns directly main object of result. All of responses are placed into ApiResult object.

Parameters of ApiResult

Name Type Required Description
Success boolean Information about if proccess resulted successfully or not.
Key string Type of response. Also each error has their own key. It's more like error code.
Data object / Generic<T> Contains main data of response. Data can be null with some unsuccessful requests.
Meta object Metadata about response, like pagination page counts or depricated elements etc.
Message string Message about request. Mostly unseuccessful requests have message about it.
IsUserFriendlyMessage boolean Indicates if Message comes from resources and readable by directly users or not.

Examples

  • A Successful listing result:
{
    "success" : true,
    "key" : "OK",
    "message" : "Completed operation successfully.",
    "data" : [
        {
            "id" : "1234",
            "title" : "Hello World!"
        },
        {
            "id" : "1235",
            "title" : "Hello World 2!"
        }
    ],
    "meta" :{
        "total" : 2,
        "page" : 1,
        "perPage": 10,
        "totalPages" : 1 
    }
}
  • A badrequest result:
{
    "success" : false,
    "key" : "ModelState",
    "message" : "Username field is required.",
    "isUserFriendlyMessage": true,
    "data" : [
        {
            "UserName" : "Username field is required."
        }
    ]
}
  • An internal server error result:
{
    "success" : false,
    "key" : "SystemError",
    "message" : "object reference not set to an instance of an object"
}

Welcome to the EasyWeb wiki!

Topics:

Clone this wiki locally