--- # How to check Rest API in Crevo Prj? # What is Rest API? Known as REpresentational State Transfer and known as RESTFULL defined as an architectural style of designing softwares a set of guidelines that software can use to communicate over the internet in order to make integrations simple and scalable a client-service architecture that is based on a request/response design. # How Does REST API work? REST APIs work by giving or passing resources, which can be accessed using standard HTTP methods. The four most common HTTP methods are GET, PUT, POST and DELETE, and each corresponds to a specific action that can be performed on a resource. For example, GET can be used to retrieve data, PUT can be used to update data, POST can be used to create new data, and DELETE can be used to delete data. In a typical REST API, a client sends an HTTP GET request to the server in order to retrieve data, and the server responds with a JSON (JavaScript Object Notation) object that contains the request data. The client can then use the data contained in the JSON object to update its own state. ***For example,*** #REQUEST GET /users HTTP/1.1 **Request URL**: http://localhost/apis/users **`The hostname of the server`** **Connection**: keep-alive **User-Agent**: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 **`The user agent string of the client`** **Accept**: application/json, text/javascript, */*; q=0.01 **`The types of data that the client accepts`** **Accept-Language**: my-MM,my;q=0.9,en-US;q=0.8,en;q=0.7 **Accept-Encoding**: gzip, deflate, br **If-Modified-Since**: Thu, 01 Jan 1970 00:00:00 GMT **Cache-Control**: max-age=2592000 ****`The cache control settings for the request`**** **Pragma**: no-cache **`The HTTP pragma for the request`** **Status Code**: 200 OK **`The status code for the response`** **Cache-Control**: no-cache **`The cache control settings for the response`** **Content-Type**: text/html; charset=UTF-8 **`The content type for the response`** **Date**: Tue, 11 Oct 2022 02:09:54 GMT **`The date and time the response was generated`** **Server**: nginx **`The server that generated the response`** **Connection**: close **`The connection status for the response`** { "users": [ { "username": "testuser001", "password": "nopassword", "email": "test@test.com", "first_name": "test", "last_name": "user" } ] } # What are the benefits? 1. Simple standardized approach to communication 2. Scable and Stateless 3. High performace # How to test Rest API in API Gateway? Test Room Id Data (Get) URL: /rooms - GET - Mothod Execution **Click Test (Client) to test API call** ![](https://i.imgur.com/sezMYxF.png) **Query Strings and Headers Value need to search where can we get** ![](https://i.imgur.com/gTNpy6h.png) **1.Check Source Code in Lamda** **2.under /rest_api/command/admin/room/get.rb** 2.1 **In Get class, check their query parameter as "id" and "auth_0_id"** ![](https://i.imgur.com/u9QVh3w.png) **1.which room data should we get, go to dynamo db** 1.1 **search rooms table and query as follow to get require data to call rest : /rooms -GET()** 1.2 **SELECT** id,auth_0_id **FROM** "crevo-dev-02-dynamodb-rooms" ![](https://i.imgur.com/uCZZMTh.png) ![](https://i.imgur.com/mx78zHo.png) **In API Gateway** /rooms -GET Method Fill data from DynamoDB into QueryParameter Sector **id=test-room-cat-725-5225&auth_0_id=test-auth-id-725-5225-12725** then , click Test Button to make request ![](https://i.imgur.com/CbmHwMq.png) **In Response Panel** show "Status"=> 200, Room Id "test-room-cat-725-5225" will be include details info under Response Body ![](https://i.imgur.com/YZjcYjU.png) ## Create Room ### Check Lamda's Code for create Room 1.1 check which route will be call to create room under "/rest-api/rest-service/room_service.rb **def** post get_command(Command::Room::Create).run end ![](https://i.imgur.com/ty8Sv08.png) 1.2 check room create function under "/rest-api/command/room/create.rb **request-Body** = { "organization_id","participant_auth_0_ids","creator_auth_0_id"} ![](https://i.imgur.com/Xnl4igf.png) Try to call Post of Room api for create new rooms **giving request Body value as** "{ "organization_id":"test-org-725", "participant_auth_0_ids":"test-auth-id-725-5225-12725", "creator_auth_0_id":"test-auth-id-3919-0" }" **Internal Error => 500 Occured** ![](https://i.imgur.com/Aefc72u.png) **Try again with other User as** "{ "organization_id":"test-org-725", "participant_auth_0_ids":"test-auth-id-725-5225-12725", "creator_auth_0_id":"test-auth-id-5225-0" }" **This creator's message list is already subscribed => 422 Occured** ![](https://i.imgur.com/lMva1vK.png)