Skip to main content

Rygen Help Center

Set HTTP Status Codes

Overview

You can set HTTP status codes to display for the different response scenarios that translators and routers handle.

Note

You can do this with REST consumers and SOAP consumers only.

Procedure
  1. In the translator handling the logic that determines the status code, set its message header with a status code.

    In the image below, the status code has been set to 500.

    http_status_codes_1.png
  2. Follow the translator with a router that contains rules for each of the status codes expected as paths to take.

    Configure the router to check the status code value and then route accordingly.

    http_status_codes_2.png

    Example Router Conditions:

    • body.document.status_code == 400

    • body.document.status_code == 500

    Note

    We recommend the following:

    • Set a default router rule that does nothing.

    • Do not set any status codes for the typical 200 HTTP status code.

  3. In each translator within the router, return the document in the document translation script.

    Also, on the Options tab, enable the Response Code Override and then specify a response code such as 400 or 500.

    http_status_codes_3.png
Result

Verify that the HTTP response displays the appropriate status code as a response.

This feature enables you to dynamically control HTTP status codes based on your business logic while maintaining proper routing and response handling.

Architecture flow

A typical flow follows this pattern:

  1. Initial translator - Sets the messageHeaders.status_code based on the processing logic.

  2. Router - Evaluates the status code and then routes to the appropriate translator.

  3. Status-specific translators - Returns the document with the proper HTTP status code override.

  4. HTTP response - The client receives a response with the correct status code.

This approach provides flexibility in handling various error conditions and success scenarios while maintaining a clean separation of concerns in your X1 integration.