← Back to Sample APIs

Addition — Data as JSON Body

Adds two integers sent as a JSON request body. Uses POST method. No authentication required. Demonstrates how to structure input as a JSON payload instead of URL parameters.

Concept: JSON Request Body · POST Method · No Auth
Addition API Series — same operation, different style
01

Endpoint

POST https://labs.lowcademy.com/apis/add-body
PropertyValue
MethodPOST
Fileadd-body.php
Content-Typeapplication/json (required)
AuthenticationNone
Input styleJSON request body
02

Authentication

No authentication required — open endpoint.
03

Request Body (JSON)

FieldTypeRequiredDescription
input1IntegerRequiredFirst integer to add
input2IntegerRequiredSecond integer to add
{
  "input1": 5,
  "input2": 3
}
04

Sample Requests

cURL

curl -X POST https://labs.lowcademy.com/apis/add-body \
     -H "Content-Type: application/json" \
     -d '{"input1": 5, "input2": 3}'

JavaScript (fetch)

const res = await fetch('https://labs.lowcademy.com/apis/add-body', {
  method : 'POST',
  headers: { 'Content-Type': 'application/json' },
  body   : JSON.stringify({ input1: 5, input2: 3 })
});
const data = await res.json();
console.log(data.result); // 8

OutSystems — POST with JSON body

// Method: POST
// Request → Body → Add structure with input1 (Integer) and input2 (Integer)
// OutSystems serialises it as: {"input1": 5, "input2": 3}
05

Response — 200 OK

{
  "success"  : true,
  "operation": "addition",
  "input1"   : 5,
  "input2"   : 3,
  "result"   : 8
}
06

Error Responses

200
OK — Result returned.
400
Bad Request — Invalid JSON, missing fields, or non-numeric values.
405
Method Not Allowed — Use POST.