Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Narasimha_Sesti
Explorer
0 Kudos

HTTP-based APIs integrate easily with RESTful web services. There are many ways to use HTTP methods to consume and update and retrieve  these API data.

Narasimha_Sesti_5-1713445164735.jpeg

HTTP API methods and understand how to use them appropriately on resources

Method 1: GET

The most common HTTP method is GET, which returns a representational view of a resource's contents and data. GET should be used in read-only mode, which keeps the data safe, You should get the same results no matter how many times you use this method, unless it is modified by another client in the interim.

Narasimha_Sesti_16-1713446097628.png

Method 2: POST

Post request used to create resource (Record ) in server, While creating record we have to pass Body data Parameters(key, values) to create the Record as JSON, Form formats are supported.

 

 Narasimha_Sesti_17-1713446242193.png

Narasimha_Sesti_26-1713448773787.png

While submitting the data we have to update Header tab content type with application/JSON.

After create new record by using browser you  will received updated data. By default Browsers using HTTP Protocol with GET method to retrieve data from service.

Narasimha_Sesti_18-1713446586084.png

Method 3: PATCH

PATCH is another HTTP method used to update resources. As opposed to replacing resources, like the PUT method does, PATCH only modifies resource contents. As a general rule, these modifications worked based on Key.

Narasimha_Sesti_19-1713446858588.png

While submitting the data we have to update Header tab content type with application/JSON.

Patch update the record based on Id, after update you will find latest records by refresh your browser.

Narasimha_Sesti_21-1713447375169.png

We have create additional record 4 for other operations in above list.

Method 5: DELETE

The last HTTP method DELETE. When a DELETE method targets a single resource, that resource is removed entirely(Hard Delete). we have to pass based on Key ID (4).

Narasimha_Sesti_22-1713447488529.png

Delete Method will delete the 4th record based on Key. after we can refresh browser data.

Narasimha_Sesti_23-1713447561137.png

Authentication

Authentication tab help to protect the API data using different security ways.

 

Narasimha_Sesti_24-1713447959184.png

 

Basic Authentication

Basic Authentication is a method of securing HTTP requests through a special header:

Authorization Tab

let’s send a GET request to a Basic Auth-secured endpoint and expect an Unauthorized status for the response:

Now, let’s add the credentials. To do this, we simply go to the “Authorization” tab and select “Basic Auth” as the authorization type. After that, we insert the username and password and we’re all set:

Narasimha_Sesti_25-1713448188952.png

 

 

2) Authorization: Basic <credentials>

To generate the credentials token, we need to write the username and password, joined by the semicolon character. After that, we need to encode the resulting string with Base64.

Let’s assume the username is “admin” and the password is “baeldung“. First, we’ll create the credentials string, which will be “admin:baeldung“. Then, we’ll encode it with Base64, add the “Basic” keyword, and set it as the header’s value:

 

What is Bearer Authentication?

HTTP provides a framework for controlling access to protected resources. HTTP authentication is performed by sending authentication credentials in the authorization header to access the protected resource. Bearer authentication (also called token authentication) is one of the HTTP authentication schemes that grant access to the bearer of this token. Bearer token authentication is done by sending a security token with every HTTP request we make to the server. You can do bearer authentication with any programming language.

Bearer Token Authentication Syntax

Authorization: Bearer {token}

 Postman displays the response data sent from the server in the lower pane.

 

Narasimha_Sesti_4-1713445164731.png