Building API Implementation Interfaces7% of the exam

Response status codes, headers and APIkit errors

How a Mule API returns the status codes and headers its RAML promises: the HTTP Listener's response and error-response settings, the httpStatus and outboundHeaders variables APIkit scaffolds, the main flow's APIKIT error handler, and hand-built 201 and 503 responses.

Official exam objective
Implement correct responses based on a RAML specification, either manually or with APIkit.

~7 min read · 6 practice questions ·

What the exam expects

  • Predict the status code and body an HTTP Listener sends by default on success and on error, and customise them with the Response and Error Response settings.
  • Return a RAML-declared status (such as 201) or header (such as Location) from a scaffolded APIkit flow with vars.httpStatus and vars.outboundHeaders.
  • Predict what happens when httpStatusVarName or outboundHeadersMapName is renamed but the listener expressions are not.
  • Change the body or status APIkit returns for a router error by editing the main flow's scaffolded error handler.
  • Return success and failure statuses (201, 503) from a hand-built listener flow, and know why On Error Propagate rather than On Error Continue is needed.
  • Key terms: response / error-response (listener settings for successful and failed flow executions); httpStatusVarName (apikit:config attribute naming the status variable, httpStatus by default); outboundHeadersMapName (names the response-headers map variable, outboundHeaders by default); reason phrase (text after the status code, such as Created).

Key facts

Listener success default
Detail
200, payload as body
Listener error default
Detail
500, error description as body
Customisable response parts
Detail
Body, Headers, Status code, Reason phrase
Status variable default name
Detail
httpStatus (httpStatusVarName)
Headers map default name
Detail
outboundHeaders (outboundHeadersMapName)
Scaffolded success status
Detail
#[vars.httpStatus default 200]
Scaffolded error status
Detail
#[vars.httpStatus default 500], body #[payload]
Renamed variable
Detail
Update the listener expressions to match
Router error bodies
Detail
Transform in each On Error Propagate of the main flow
On Error Continue
Detail
Owner completes as if successful
Sources for this section (4)
  • Which four parts of a listener response can you customise?
  • Why does an error that never sets httpStatus still get a status code from the scaffolded listener?
  • When does the scaffolded console flow's error handler run?
  • Which apikit:config attributes name the response variables, and what are their defaults?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the MuleSoft Developer pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 40 lessons of the MuleSoft Developer guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Practice exams purchase adds inline bank questions and topic practice (6 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the MuleSoft Developer exam