HTTP Methods , Restful API Methods , URI examples

GET METHOD :

HTTP GET http://oms.com/orders/1
HTTP GET http://oms.com/orders

POST METHOD :

HTTP POST http://oms.com/orders/
HTTP POST http://oms.com/users/1/products

The difference between the POST and PUT APIs can be observed in request URIs. POST requests are made on resource collections, whereas PUT requests are made on an individual resource.

PUT METHOD :
HTTP PUT http://oms.com/orders/1/gg@gmail.com
HTTP PUT http://oms.com/users/2/orders/2

DELETE METHOD :

HTTP DELETE http://oms.com/orders/2
HTTP DELETE http://oms.com/users/3

PATCH METHOD :

PATCH is used to partial update on a  resource not like PUT which is used for entire resource update.

HTTP PATCH http://oms.com/orders/1/users/2/hh@gmail.com



What is the difference between PUT and POST methods in Rest API ?

PUT method is idempotent. Which means it produces same result . How many times you call that mention the result will be same.

Where Post method will produce different result when ever you call that function.

Post method is used to create a new resource.

PUT method is used in general to update a resource .



LeetCode - Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
    1 -> A
    2 -> B
    3 -> C
    ...
    26 -> Z
    27 -> AA
    28 -> AB 
    ...
Example 1:
Input: 1
Output: "A"
Example 2:
Input: 28
Output: "AB"
Example 3:
Input: 701
Output: "ZY"
Java Solution :
class Solution {
    public String convertToTitle(int n) {
        
        StringBuilder sb = new StringBuilder();
        
        while(n > 0){
            n--;
            char ch = (char) (n%26 + 'A');
            n = n/26;
            sb.append(ch);
        }
        sb.reverse();
        return sb.toString();
        
    }
}

Featured Post

H1B Visa Stamping at US Consulate

  H1B Visa Stamping at US Consulate If you are outside of the US, you need to apply for US Visa at a US Consulate or a US Embassy and get H1...