4.2.4.14. Rest Gateway In
This gateway in allows you to easily publish a REST api.
It has the following characteristics:
- It will respond synchronously to the REST api calls with the result of the processing of the message by the channels.
- It injects an xml message in that contains all the elements of the REST call (uri, parameters, expected output format, ...).
- It supports 'json', 'xml' and 'csv' as output format.
- It supports multi-credentials.
The specific settings are:
Part of the url that identifies this gateway. The urls to call the REST api will have the form https://ws.babelway.net/rest/ |
|
Activate this settings if you want to use the body of the API call (also known as the payload of the HTTP call) as message IN content. This only works with POST, PUT and PATCH HTTP methods. If you deactivate this options, your message content will look like the XML example we provided in the help guide. |
|
The URL to call the REST api. |
|
A list of user names/password pairs that are allowed to access this api. The user will have the choice to provide user name and password via http basic authentication, http settings 'user' and 'password' or http headers 'user' and 'password'. |
|
Optional. If filled, the requested url will be checked again. This pattern will be refused if it doesn't match at least one pattern. You can also prefix the pattern with 'PRE:', 'POST:', 'PUT:', ... if you want this pattern to only be accessible via one specific http method. |
Here is an example of message In, that is generated by this gateway if you use the HTTP method POST.
<?xml version="1.0" encoding="UTF-8"?> <restRequest> <uri>/sws/shipmentStatus/BE.json</uri> <identifier>sws</identifier> <action>shipmentStatus</action> <method>GET</method> <format>json</format> <userName>bertrand</userName> <parameters> <param1>BE</param1> <myParam>myValue</youpie> </parameters> <POST>... Payload or body of your HTTP call ... </POST> </restRequest>
xml tags will match the HTTP method you use to perform the call. Those would be if you are using the GET method, etc...
Below is how to use the URL parameters for a REST API Server Gateway IN
For example we have created the REST API Server Gateway IN with the below parameters as a test values for explanation
1-The "Url identifier" as "testurl".
2-Regarding the "Allowed credentials" the "Username" as "usernametest" and the "Password" as "passwordtest".
3-For this test environment the "Url to call" is "http://ws.babelway.net/rest/testurl/message(?URL Params).(json|xml)"
To use the URL settings for a REST API Server Gateway IN, for example, this is the Url to call "http://ws.babelway.net/rest/testurl/message(?URL Params).(json|xml)"
You will replace the (?URL Params) with your URL params you want to use them.
Regarding the (json|xml) here you can determine the format of the data.
Note: If you want to get the input message name then you have to select one of the two below mentioned options. This is due to the fact that, when using the REST API Server Gateway IN there is no file.
- Option one: You will need to include the input file name somewhere in the API call in the body of the HTTP call.
- Option two: You will need to include the input file name somewhere in the URL parameters.
Now you can use the name that you have provided by selecting one of the two above mentioned options to create the output message file name.
Note:
- If there is a file name provided in the "Message In" or "Message Out" which contain ~ tilde character, All browser based on Chromium will replace the ~ tilde character by the _ underscore character when you try to download the file from the Babelway interface, For more details you can check this link https://bugs.chromium.org/p/chromium/issues/detail?id=479419
- You can check bunch of info like last success date, last message date …etc. by pressing on Run Info button.
- Our synchronous Gateways is not covering the FULL processing of the message but only until the generation of the MessageOUT.
- The maximum file size accepted by this gateway is 100 MB.