← Back to Sample APIs

Addition — Returns a Plain Integer

Adds two integers and returns just the number as plain text — no JSON wrapper. Content-Type: text/plain. Demonstrates that an API response doesn't have to be JSON.

Concept: Plain Integer Response · text/plain · No JSON wrapper
Addition API Series — same operation, different style
01

Endpoint

GET https://labs.lowcademy.com/apis/add-int?input1=5&input2=3
PropertyValue
MethodGET
Fileadd-int.php
AuthenticationNone
Response Content-Typetext/plain
Response bodyA single integer — e.g. 8
02

Authentication

No authentication required — open endpoint.
03

Query Parameters

ParameterTypeRequiredDescription
input1IntegerRequiredFirst integer
input2IntegerRequiredSecond integer
04

Response Comparison — Integer vs JSON

This API — text/plain
8
JSON version (add-url.php)
{
  "success": true,
  "operation": "addition",
  "input1": 5,
  "input2": 3,
  "result": 8
}

In OutSystems, consuming a plain integer response is mapped differently — instead of deserialising a JSON structure you read the raw response body as text/integer. Most production APIs use JSON, but the integer style appears in legacy and embedded systems.

05

Sample Requests

cURL

curl https://labs.lowcademy.com/apis/add-int?input1=5&input2=3
# Response: 8

JavaScript (fetch)

const res    = await fetch('https://labs.lowcademy.com/apis/add-int?input1=5&input2=3');
const result = await res.text(); // NOT .json() — plain text!
console.log(Number(result)); // 8
06

Error Responses

Error responses are also plain text (not JSON) to stay consistent with the Content-Type.

200
OK — Plain integer returned. e.g. 8
400
Bad Request — Plain text error message.
405
Method Not Allowed — Plain text error.