Mainframe Path Start learning free
Applied8 min readLesson 1 of 5

REST in plain terms

A REST API lets one program ask another for something over HTTP, the same protocol web browsers use. The request names a resource, such as an account, and an action, such as read or update; the reply carries a status code and data, usually in JSON.

A transaction by another name

You already know the shape. A CICS transaction receives an input message, runs a program, and returns an output message. A REST call is the same idea with standard packaging: the input is an HTTP request, the program behind it does the work, and the output is an HTTP response.

HTTP methodMeaningRough SQL equivalent
GETRead a resourceSELECT
POSTCreate a new resourceINSERT
PUTReplace a resourceUPDATE (whole row)
PATCHChange part of a resourceUPDATE (some columns)
DELETERemove a resourceDELETE

Status codes are return codes

Every response starts with a three-digit status code, which plays the same role as a return code: callers check it before looking at the data.

z/OS already speaks REST

z/OSMF provides REST services for everyday system tasks: listing datasets, reading members, submitting jobs and reading their output. Tools such as Zowe are built on them. Seeing one call makes the idea concrete.

Listing your jobs through the z/OSMF REST API
$ curl -u USERID "https://zosmf.example.com/zosmf/restjobs/jobs?owner=USERID"
 
HTTP/1.1 200 OK
[ { "jobname": "PAYRUN01", "jobid": "JOB04512",
    "status": "OUTPUT", "retcode": "CC 0000" } ]

Common mistakes

Using GET to change data

GET must only read. Caches and retries assume it is safe to repeat; an update hidden behind GET can be applied several times.

Returning 200 for every error

If failures come back as 200 with an error message inside, callers miss them. Use the right status code, exactly as you would set a non-zero return code.

Thinking REST replaces CICS

The API is a front door. The business logic still runs in the same CICS, IMS or batch programs.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
From copybook to JSON →