The video tutorial below demonstrates how to create an API endpoint that handles HTTP Requests with Headers. Headers can be defined for endpoints that respond to GET, POST, PUT and DELETE requests.
API RequestRequest Path: /product/addHTTP Method: GET Request HeadersHeaders Count: 2 Header Name : authorization Header Value: Bearer token1 Header Name: app-id Header Value: app-88
HTTP Request Body
{ "name": "tv", "description": "65inch - 4K", "manufacturer": "xyz", "model": "X12345678990", "price": "$650.00", "smart": true }
API ResponseResponse Code: 201Response Content-Type: application/jsonResponse Body:
{ "message":"new item added successfully", "success": true }
Alternate Response # 1Response Code: 201Response Content-Type: application/jsonResponse Body:
Alternate Response # 2Response Code: 403Response Content-Type: application/jsonResponse Body:
{ "message": "cannot add new item, permission denied", "success": false }
Alternate Response # 3Response Code: 422Response Content-Type: application/jsonResponse Body:
{ "message": "invalid/unknown fields were found in the request body, cannot process the request", "success": false }
Alternate Response # 4Response Code: 500Response Content-Type: text/plainResponse Body:
Internal Server Error - Contact API Team if the problem persists