Create REST API in ServiceNow

preview_player
Показать описание
REST : Representational State Transformation

Representational - Same data/resource we can represent in different ways
State - state of the data
Transfer - exchanging data

API - Application Programming Interface (Interface that allow us to connect two different application)

We create interface to connect to the database to send/receive data over the internet through HTTP protocol.

Rest is all about managing resources(CRUD).

PATH parameters:

QUERY parameters

offset = starting point
limit = how many records you want

Status code help us to understand what has happened with our request.

100 - Informational Status
200 - Success Status
300 - Redirectional status
400 - Client Side Error
500 - Server Side Error

200 = Resource has been updated/created and it can return all information.
201 = Resource has been updated/created however it will return few details.
400 = Fault with client side.(Invalid request payload or headers)
409 = Entity you are creating already exists in the system.
404 = Not found error

To handle REST Error

var sn_ws_err=new sn_ws_err.ServiceError(); // Custom errors

// setStatus(code);
// setDetails(str/obj/num);
// setMessage(message);

// new sn_ws_err.ConflictError('error message'); // 409
// new sn_ws_err.NotFoundError('error message'); // 404

What are HTTP headers?
Answer: Headers are part of request which is used to exchange metadata with respect to the request, which doesn't have anything to do with actual resources.
Рекомендации по теме
Комментарии
Автор

absolutely awesome I was searching for this !

DonDomel
visit shbcf.ru