HTTP Request
Last updated
Last updated
When this node is reached, an HTTP request will be executed. The HTTP request node supports:
All common request methods (GET
, POST
, PUT
, DELETE
, PATCH
, etc.);
Query parameters (expressions);
Basic authentication and Client certificate authentication;
Custom request headers (expressions);
Custom response headers (mapped to fields);
If applicable, a request body (text, file or richtext);
Response body (text, file or richtext).
The type of request, and the HTTP request details are all specified in the node’s properties. Some properties are only needed for certain request types, as is displayed in the example below.
The properties:
The Web request node can have several exits. There are two pre-defined exits:
Default exit
Error
This is the standard error exit for every WEM Node to catch technical code issues within the node itself to prevent showing technical error-details to end users. In this case it should not be used to handle Fault Messages from the Response (which are correct results within the HTTP Request Process - not errors - and have specific HTTP Response Codes which can be handled specifically)
Besides these pre-defined exits, it is possible to define an exit for every possible status code the HTTP Request returns. This includes any "error messages" or "fault messages" that the remote endpoint can provide.
List of HTTP Status Codes:
The HTTP Request Node allows you to add exits for specific HTTP Status Codes (or response codes) that the resulting Response can provide. A link to a list of possible HTTP status codes and types/grouping is provided above and here: (wiki).
You should check with the provider of the remote endpoint to understand which Response Codes you may expect and could handle specifically.
When you define the Exit by HTTP Code, you currently have to define the specific code (there is no option for "wildcards" like 4xx and 5xx - but this may be provided in future). Then, following the specific HTTP Code Exit, you can handle it accordingly, and the Response Body can contain details of the specific situation so you may want to use that Response Body information as well when displaying feedback to user.
HTTP Status Code Exit or Error Exit?
Basically, you will not use the Error Exit to handle errors that occur on the Remote side - the Error Exit should only be used for situations where the Response is not received (there is no HTTP Status Code) - typically this is for when the Request itself is malformed and causes issues in the WEM Runtime. You should leave the Error Exit unlinked to show the technical information from the WEM Runtime that may indicate a bug or another issue that needs to be fixed. To make things confusing: that error may be displayed as a Server 500 (HTTP Status code 500) error, but this may be the status code from the WEM Runtime, and not from the remote endpoint...
HTTP Status Codes in the 4xx range are considered "client errors" and the 5xx range are considered "server errors" - in any case - if this status code is received in the Response object and there is a corresponding exit, this exit is followed and the Response Body will contain the detailed results from the remote endpoint. As this is mapped to a field in your model, you can just display that information or work some logic on its contents.
HTTP Status Codes 4xx and 5xx as received from the remote endpoint are valid Response Status Codes and are NOT considered Errors that will follow the Error Exit.
Item
Options
Description
Name
Name of the node. This name is generated by WEM and describes the HTTP request that will be performed. The property cannot be edited by hand.
URL
The URL that is used for the HTTP request (the server to which the request is sent)
Method
GET
,POST
, PUT
, PATCH
, DELETE
, HEAD
, TRACE
, OPTIONS
The HTTP request method that is used in this node
Follow Redirect
Yes/No (checkbox)
Authentication
- None - Basic Authentication - Client Certificate
Specifies if authentication is needed for the request. And if so, what type of authentication. When the ‘Basic Authentication’ is specified, a simple username/password suthentication is used. In this case the Username and Password properties are displayed. When the ‘Client Certificatie’ authentication is used, the user is asked to specify the client certificate. The certificate must be available in WEM.
Request Body
A custom request body can be defined
Response Body
A custom response body can be defined
Edit Query fields
Edit Request Headers
Edit Response Headers