API headers - What do I know about them

     In this post I want to talk about what I've learned about API headers. Recently I downloaded a free book on apple books app, "An Introduction to API" by Brain Cooksey. The author has explained information in simple terms with beginners in mind. 

 What are API headers? 
     Headers provide meta information about the request and response. They are items like, the client's request time, size of the request body, user-agent, content type of the request payload, authentication information... 
Commonly used headers: 
 1. "User-Agent": The client uses this header to tell the server what type of device you are using. 
       Ex: 
           Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15; 
           PostmanRuntime/7.32.3 

 2. "Content-Type": The client is telling the server that data in the request body is formatted a particular way. The server will also set the content type header for response to tell the client how to read the respose data. 
       Ex: 
          application/x-www-form-urlencoded 
          application/json 

 3. "Accept": Sometimes the client can understand response in one format, so The client is telling the server that it accepts the response in particular format. 
      Ex: 
          application/json 
          */* 

 4. "Authorization": "the HTTP header used to hold credentials" 
       Ex: 
          Bearer eyJ2ZXIiOjIsImVudiI6IlFBIiwiYWxnIjoiUlMyNTYi..... 
          Basic dXNlcjpwYXNzd29yZA==


  Try testing the api request with different values for the headers and observe the behavior, response time and status code.

  Happy testing !!

Comments

Popular posts from this blog

API Testing journey

My first time attending a software launch party