REST

things every developer should know

What is REST protocol?

REST, or REpresentational State Transfer, is an architectural style for providing standards between computer systems on the web, making it easier for systems to communicate with each other. REST-compliant systems, often called RESTful systems, are characterized by how they are stateless and separate the concerns of client and server.

MAKING REQUESTS

REST requires that a client make a request to the server in order to retrieve or modify data on the server. A request generally consists of:

  • an HTTP verb, which defines what kind of operation to perform

  • a header, which allows the client to pass along information about the request

  • a path to a resource

  • an optional message body containing data

HTTP VERBS

There are 4 basic HTTP verbs we use in requests to interact with resources in a REST system:

  • GET — retrieve a specific resource (by id) or a collection of resources

  • POST — create a new resource

  • PUT — update a specific resource (by id)

  • DELETE — remove a specific resource by id


RESPONSE CODES

Responses from the server contain status codes to alert the client to information about the success of the operation. As a developer, you do not need to know every status code (there are many of them), but you should know the most common ones and how they are used:

Status codeMeaning

200 (OK) - This is the standard response for successful HTTP requests.

201 (CREATED) - This is the standard response for an HTTP request that resulted in an item being successfully created.

204 (NO CONTENT) - This is the standard response for successful HTTP requests, where nothing is being returned in the response body.

400 (BAD REQUEST) - The request cannot be processed because of bad request syntax, excessive size, or another client error.

403 (FORBIDDEN) - The client does not have permission to access this resource.

404 (NOT FOUND) - The resource could not be found at this time. It is possible it was deleted, or does not exist yet.

500 (INTERNAL SERVER ERROR) - The generic answer for an unexpected failure if there is no more specific information available.


To facilitate the interaction between the client and the server, Cangooroo's REST WebServices use JSON format text files in their requests and their responses, the files in JSON are simple to interpret, text parameters can be identified by placing them double quotes ("example"), Boolean parameters and numbers can be sent normally without special formatting.


Request and Response examples :

request:

[POST] https://ws-pp.cangooroo.net/ws/Rest/ExampleRest.svc/SearchTest

Body: {

"Credential": {

"Username": "Your_Username",

"Password": "Your_Password"

}

"IsAdult": true

}

Response:

HTTP: code 200 OK

[{ "Id": 1, "Name": "ABC", "IsAdult": true }]


Tools

Below are some of the tools we recommend you use when it comes for Webservice integration, testing and providing us with all the information we might need to try and help you.

Please remember that we do not give any support to the tools below.

    1. Fiddler - used to capture http requests / responses.

    2. Postman - used to test Webservices (we use it to test Rest Webservices).