HTTP Redirect rule

Use this rule to manage HTTP redirection for API requests

Manages HTTP redirection. When an HTTP response contains a 3xx HTTP status code, the client side handles the redirect as defined in the rule.

Rule Execution Order

Transformation of request headers works in the following rule sequence for both APIs and Proxies:

Authorize By Role ➡️ Authentication rule ➡️ Traffic rule ➡️ HTTP Redirect

Architecture

In this context, the client side is called the user-agent. For APIM, the user-agent might be a web browser, HTTP client, or cURL application. Since the user-agent is responsible for handling the response, the rule assumes that the user-agent (and not the server) performs the redirects; this includes processing follow-on HTTP methods, payload content, and redirect addresses. The server (Snaplex) is only responsible for setting the Response status type, status code, location header, and, where defined, the message content.



Limitations

Only message bodies for application/json and application/xml content types are validated by the UI.

Field Description
When this rule should be applied An expression that defines one or more conditions that must be true for the rule to execute.

Default value: N/A

Example: The expression request.method == "POST" causes the rule to execute only on POST requests.

HTTP Redirect Properties The controls for HTTP redirection. Each property defines a condition to return a HTTP redirect response. Each property also includes fields for specifying the redirect URL, content-type, and message body for the HTTP response. Click Plus Icon to add redirect properties to the rule. To remove the redirect property, click Minus Icon and click Validate @amp; save.
Use User-Agent Content Select this checkbox to redirect an HTTP user-agent with the user-agent’s original request contents, such as the content type, message body, and query parameters.
Tip: Deselecting this checkbox does not remove the redirect property.

Default status: Deselected

Condition Required. Enter an expression to prompt an HTTP redirect when it evaluates to True. An expression that evaluates to False will not prompt an HTTP redirect response.

Default value: N/A

Response Status Required. Select one of the following:
  • 300 - Multiple Choices. The request has more than one possible response. The user-agent or user should choose one of them. (There is no standardized way of choosing one of the responses, but HTML links to the possibilities are recommended so the user can pick.)

  • 301 - Moved Permanently. The URL of the requested resource has been changed permanently. The new URL is given in the response.

  • 302 - Found. This response code means that the URI of requested resource has been changed temporarily. Further changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests.

  • 303 - See Other. This is used for caching purposes. It tells the client that the response has not been modified, so the client can continue to use the same cached version of the response.

  • 307 - Temporary Redirect. The server sends this response to direct the client to get the requested resource at another URI with the same method that was used in the prior request. This has the same semantics as the 302 Found HTTP response code, with the exception that the user-agent must not change the HTTP method used: if a POST was used in the first request, a POST must be used in the second request.

  • 308 - Permanent Redirect. This means that the resource is now permanently located at another URI, specified by the Location: HTTP Response header. This has the same semantics as the 301 Moved Permanently HTTP response code, with the exception that the user-agent must not change the HTTP method used: if a POST was used in the first request, a POST must be used in the second request.

Default value: 300 - Multiple Choices

Redirect URL Click to specify an expression to build a valid URL.
Note:

Some functions in the dropdown list might not be applicable and therefore will not work. Alternatively, you can disable the Expression field to enter the URL for the redirection.

Example: https://docs-snaplogic.atlassian.net/wiki/search?text=client

Default value: N/A

Content-Type Click to specify a function. For expressions containing a semi-colon (;), you can use escape() to allow the expression to compile. For example: escape("text/xml; charset=utf-8")

You can add other content types recognized by IANA, such as:application/alto-error+json escape("application/alto-error+json; charset=windows-1252")

Note:
Some functions in the dropdown list might not be applicable and therefore will not work.Alternatively, select the content type from the dropdown:
  • application/json
  • application/xml
  • text/html
  • text/plain
  • text/xml

Default value: N/A

Message Body Enter a message for the API caller. Example:
{
    "Hello":"World"
}

Default value: N/A

Description

Required.

Default value: Requests that meet the criteria are being redirected according to the specified rules

Example: HTTP redirection scheme