This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| scripting:restapi [2022/10/01 10:38] – jotasandoku | scripting:restapi [2023/11/02 14:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | **__POSTMAN TUTO__**\\ | + | __REST API (OR REST-API)__ |
| - | INSTALL POSTMAN: [[https://learning.postman.com/docs/getting-started/installation-and-updates/#installing-postman-on-linux|External Link]]\\ | + | \\ |
| - | | + | __BUILDING THE URL__ |
| - | | + | \\ |
| - | sudo ln -s /opt/Postman/Postman / | + | [[https:// |
| + | \\ | ||
| + | | ||
| + | | ||
| + | * Endpoint: endpoint is the whole URL. Leftside is Domain name; Rightside is URI | ||
| + | * A group of **resources** is called a **collection.** | ||
| + | | ||
| + | | ||
| - | * PASSWORD MANAGEMENT: For authentication, | + | ---- |
| - | * Other popular authentication methods: 'token bearer' | + | FILTERS: |
| - | * CODE GENERATED: Note verify=False for the ssl verification & removed: cache-control and postman-token | + | |
| - | {{: | + | |
| - | * Accept header: Note that this is misleading. It goes in the request | + | * [[https:// |
| + | * Match booleans: ongoing.eq.true | ||
| + | \\ | ||
| + | * The URL above has **two parameters** separated by **&** | ||
| + | * The second parameter has **two terms** separated by ' AND ' | ||
| + | |||
| + | |||
| + | * If we are told to separate anything with Space, | ||
| + | * [[https:// | ||
| + | |||
| + | |||
| + | __SECURITY__ [[https:// | ||
| + | * CREDENTIALS: | ||
| + | * Token bearer | ||
| + | * Non-standard token (in the header itself): | ||
| + | | ||
| + | | ||
| + | |||
| + | __Rest API resource '' | ||
| + | \\ | ||
| + | | ||
| + | * BACKEND should use/store numeric (ID) primary keys for its logics | ||
| ---- | ---- | ||
| + | |||
| + | * [[https:// | ||
| + | * Sample domains: | ||
| + | * [[http:// | ||
| + | * [[https:// | ||
| + | |||
| + | ---- | ||
| + | |||
| **CURL** | **CURL** | ||
| \\ | \\ | ||
| - | **TODO: curl most common flags** | + | **TODO: curl most common flags** |
| + | * -H (header) | ||
| + | * -X (request verb to use. Example -X PUT) | ||
| \\ | \\ | ||
| **CRAFTED REQUESTS**\\ | **CRAFTED REQUESTS**\\ | ||
| Line 41: | Line 77: | ||
| Also see curl examples in [[https:// | Also see curl examples in [[https:// | ||
| - | curl --socks5 127.0.0.1: | + | curl --socks5 127.0.0.1: |
| - | + | ||
| - | ---- | + | |
| - | __BUILDING THE URL__ | + | |
| - | \\ | + | |
| - | * Parameters | + | |
| - | * Terms | + | |
| - | * Endpoint: endpoint is the whole URL. Leftside is Domain name; Rightside is URI | + | |
| - | * A group of **resources** is called a **collection.** [[https:// | + | |
| - | * | + | |
| - | * method, headers, data(body) [[https:// | + | |
| - | + | ||
| - | [[https:// | + | |
| - | \\ | + | |
| - | * The URL above has **two parameters** separated by **&** | + | |
| - | * The second parameter has **two terms** separated by ' AND ' | + | |
| - | + | ||
| - | + | ||
| - | * If we are told to separate anything with Space, this is how is encoded in the URL : '' | + | |
| - | + | ||
| - | __CREDENTIALS__ | + | |
| - | \\ | + | |
| - | * Token bearer | + | |
| - | * Non-standard token (in the header itself): | + | |
| - | * Content-Type : Content-Type | + | |
| - | * X-Arbux-APIToken : xxxxxxx | + | |
| - | + | ||
| - | __Rest API resource '' | + | |
| - | \\ | + | |
| - | * REST API should expose named UUID-V3 identifier. UUID should be generated from the resource logical key | + | |
| - | * BACKEND should use/store numeric (ID) primary keys for its logics | + | |
| ---- | ---- | ||
| Line 172: | Line 177: | ||
| Pragma: no-cache | Pragma: no-cache | ||
| Cache-Control: | Cache-Control: | ||
| - | | ||
| - | * Connection: keep-alive or close | ||
| - | \\ | ||
| METHOD \\ | METHOD \\ | ||
| * GET - used when retrieving data | * GET - used when retrieving data | ||
| Line 189: | Line 191: | ||
| \\ | \\ | ||
| - | AUTHENTICATION | + | AUTHENTICATION |
| \\ | \\ | ||
| * You need to know the authentication type to use. Basic HTTP, and OAuth are common types. | * You need to know the authentication type to use. Basic HTTP, and OAuth are common types. | ||
| * Authentication credentials | * Authentication credentials | ||
| - | \\ | ||
| \\ | \\ | ||
| CUSTOM HEADER: | CUSTOM HEADER: | ||
| * Does the API require you to send any HTTP Headers? | * Does the API require you to send any HTTP Headers? | ||
| * Example: Content-Type: | * Example: Content-Type: | ||
| - | \\ | ||
| \\ | \\ | ||
| REQUEST BODY\\ | REQUEST BODY\\ | ||
| JSON or XML containing data that is needed to complete request can be sent in the body of the request | JSON or XML containing data that is needed to complete request can be sent in the body of the request | ||
| + | \\ | ||
| + | CONNECTION: | ||
| + | Only values are '' | ||
| ---- | ---- | ||
| Line 215: | Line 217: | ||
| console.log(myObj.People[1].Lastname); | console.log(myObj.People[1].Lastname); | ||
| + | | ||
| + | | ||
| + | ---- | ||
| + | | ||
| + | INSTALL POSTMAN: [[https:// | ||
| + | ~Download it in Downloads folder | ||
| + | sudo tar -xvzf ~/ | ||
| + | sudo ln -s / | ||
| + | |||
| + | * PASSWORD MANAGEMENT: For authentication, | ||
| + | * Other popular authentication methods: 'token bearer' | ||
| + | * CODE GENERATED: Note verify=False for the ssl verification & removed: cache-control and postman-token | ||
| + | {{: | ||
| + | |||
| + | * Accept header: Note that this is misleading. It goes in the request (GET) and specifies **the media types which are acceptable for the response**. | ||