REST API Error Handling

Zhebrunov Grigorii
Jan 2, 2018 · 9 min read


{
"error": "Employee with Id 123 was not found"
}


{
"statusCode": "404",
"errorCode": "EeNotFound_10",
"message": "Requested resource was not found",
"developerMessage": "Employee with Id 123 was not found in the company 700",
"timestamp": "Wed, 05 Jul 2017 23:16:16 GMT",
"moreInfo": "http://documentationportal.com/api/errors?code=EmployeeNotFound_10"
}

{
...
"moreInfo": {
"link": "http://documentationportal.com/api/errors?code=EmployeeNotFound_10",
"rel": "help",
"title": "Employee Not Found"
}
}

{  
"statusCode": "404",
"errorCode": "EeNotFound_10",
"message": "Requested resource was not found",
"developerMessage": "Employee with Id 123 was not found in the company 700",
"timestamp": "Wed, 05 Jul 2017 23:16:16 GMT",
"_links": {
"self": { "href": "/employees/123" },
"help": {
"href": "http://documentationportal.com/api/errors?code=EmployeeNotFound_10",
"type": "text/html",
"title": "Employee Not Found"
}
}
}
{

"developerMessage": "Employee with Id 123 was not found in the company 700",
"_links": {
"self": { "href": "/employee/123" },
"help": {
"href": "http://documentationportal.com/api/errors?code=EmployeeNotFound_10",
"type": "text/html",
"title": "Employee Not Found"
},
"company": { "href": "/companies/700" }
}
}
}
{
"statusCode": "404",
"errorCode": "EeNotFound_10",
"message": "Requested resource was not found",
"developerMessage": "Employee with Id 123 was not found in the company 700",
"timestamp": "Wed, 05 Jul 2017 23:16:16 GMT",
"_links": {
"self": { "href": "/employees/123" },
"help": {
"href": "http://documentationportal.com/api/errors?code=EmployeeNotFound_10",
"type": "text/html",
"title": "Employee Not Found"
},
"company": { "href": "/companies/700" }
},
"_embedded": {
"companies": [{
"_links": {
"self": { "href": "/companies/700" }
},
"id": 700,
"name": "Company With No Employee"
}]
}
}

Zhebrunov Grigorii

Written by

Lead Developer, ECS Limited

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade