HTTP Requests


The HTTP protocol is the foundation of RESTful APIs, enabling communication between clients and servers.

The core HTTP methods are used to perform CRUD (Create, Read, Update, Delete) operations on resources, essential for managing data in IoT applications:


Requests and Responses

A request is initiated by the client and sent to the server, while a response is sent back by the server to the client.

Requests and responses are the basis of data exchange in RESTful APIs.


Request Components

Request header

Host: website.com 
User-Agent: Chrome/5.0 (Windows 10) 
Accept-Language: en-US 
Accept-Encoding: gzip, deflate 
Connection: keep-alive</code.

HTTP GET request

GET /data/latest HTTP/1.1

Response Components

HTTP GET successful request response

HTTP/1.1 200 OK

HTTP GET error in request response

HTTP/1.1 400 OK

here, the HTTP status code 400 means that there is a problem in the client-side (request does not have what it needs).

Response body

HTTP/1.1 200 OK 
Date: Mon, 27 Jul 2022 12:28:53 GMT 
Server: Apache/2.2.14 (Win32) 
Last-Modified: Wed, 22 Jul 2022 19:15:56 GMT 
Content-Length: 88 
Content-Type: text/html 
Connection: Closed 
<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”></code.

These examples were extracted from What Is an HTTP Request?