Difference between revisions of "I2Rest API"
Line 3: | Line 3: | ||
i2Rest Server provides a set of web services to call IBM i programs and commands, as well as APIs to manage i2Rest Server instance. | i2Rest Server provides a set of web services to call IBM i programs and commands, as well as APIs to manage i2Rest Server instance. | ||
− | |||
− | |||
Management APIs includes functions that can be used to do some management stuff - change runtime parameters, query current status of server instance, etc. Management APIs are available at [[i2Rest Gates#management_gate|Management Gate endpoint]], for clients who have OAuth2 tokens with management_functions scope. | Management APIs includes functions that can be used to do some management stuff - change runtime parameters, query current status of server instance, etc. Management APIs are available at [[i2Rest Gates#management_gate|Management Gate endpoint]], for clients who have OAuth2 tokens with management_functions scope. | ||
Line 11: | Line 9: | ||
== run_program API == | == run_program API == | ||
+ | This API allows you to call IBM i programs as Json REST web service. To call IBM i program, you must prepare file describing program parameters in [[i2Rest Server PCML|PCML format]], and publish this description to i2Rest Server. | ||
+ | |||
+ | It is required to obtain OAuth2 token with run_program scope to call IBM i programs. | ||
+ | |||
+ | === run_program API URL === | ||
+ | API run_program is available on [[i2Rest Gates#main_gate|Main Gate endpoint]]. The URL for run_program API of specific program is as follows: | ||
+ | |||
+ | <pre>http[s]://<your_i2Rest_server>/run_program/<pcml_mount_point>/<pcml_program_name></pre> | ||
+ | where: | ||
+ | * <tt>your_i2Rest_server</tt> - host name and optional port of i2Rest Server instance (defined in [[Gate_object|Main Gate Config]]) | ||
+ | * <tt>pcml_mount_point </tt> - [[Deploy PCML|mount name]] where PCML file is deployed | ||
+ | * <tt>pcml_program_name </tt> - program name as defined in [[PCML file]] | ||
+ | |||
+ | example: | ||
+ | <pre>https://i2rest.com/run_program/echo/echo</pre> | ||
+ | |||
+ | === run_program API parameters === | ||
+ | To call run_program API, you must send POST request with following JSON object as request body (media type 'application/json'): | ||
+ | {| style="width: 100%; vertical-align:top; border-collapse:collapse" border="1" | ||
+ | | style="width: 10%; padding: 5px"|'''Field''' | ||
+ | | style="width: 10%; padding: 5px"|'''Type''' | ||
+ | | style="width: 40%; padding: 5px"|'''Description''' | ||
+ | | style="width: 40%; padding: 5px"|'''Default value''' | ||
+ | |-style="vertical-align:top;" | ||
+ | |style="padding: 5px"|input | ||
+ | |style="padding: 5px"|object | ||
+ | |style="padding: 5px"|'''Input parameters object'''<br/> | ||
+ | The structure of input parameters depends on the program call definition described in appropriate PCML document | ||
+ | | | ||
+ | |-style="vertical-align:top;" | ||
+ | |style="padding: 5px"|tracein | ||
+ | |style="padding: 5px"|boolean | ||
+ | |style="padding: 5px"|'''Trace input parameters'''<br/> | ||
+ | Boolean flag to specify the requirement to print input parameters in job log. If true, all input parameters will be printed in session job log before performing call to program | ||
+ | |style="padding: 5px"|<tt>false</tt> | ||
+ | |-style="vertical-align:top;" | ||
+ | |style="padding: 5px"|traceout | ||
+ | |style="padding: 5px"|boolean | ||
+ | |style="padding: 5px"|'''Trace output parameters'''<br/> | ||
+ | Boolean flag to specify the requirement to print output parameters in job log. If true, all output parameters will be printed in session job log after call to program | ||
+ | |style="padding: 5px"|<tt>false</tt> | ||
+ | |} | ||
+ | |||
+ | |||
== run_command API == | == run_command API == | ||
+ | It is required to obtain OAuth2 token with run_command scope to call IBM i commands. API run_command is available on [[i2Rest Gates#main_gate|Main Gate endpoint]] | ||
== Management APIs == | == Management APIs == |
Revision as of 17:48, 6 April 2020
i2Rest API
i2Rest Server provides a set of web services to call IBM i programs and commands, as well as APIs to manage i2Rest Server instance.
Management APIs includes functions that can be used to do some management stuff - change runtime parameters, query current status of server instance, etc. Management APIs are available at Management Gate endpoint, for clients who have OAuth2 tokens with management_functions scope.
run_program API
This API allows you to call IBM i programs as Json REST web service. To call IBM i program, you must prepare file describing program parameters in PCML format, and publish this description to i2Rest Server.
It is required to obtain OAuth2 token with run_program scope to call IBM i programs.
run_program API URL
API run_program is available on Main Gate endpoint. The URL for run_program API of specific program is as follows:
http[s]://<your_i2Rest_server>/run_program/<pcml_mount_point>/<pcml_program_name>
where:
- your_i2Rest_server - host name and optional port of i2Rest Server instance (defined in Main Gate Config)
- pcml_mount_point - mount name where PCML file is deployed
- pcml_program_name - program name as defined in PCML file
example:
https://i2rest.com/run_program/echo/echo
run_program API parameters
To call run_program API, you must send POST request with following JSON object as request body (media type 'application/json'):
Field | Type | Description | Default value |
input | object | Input parameters object The structure of input parameters depends on the program call definition described in appropriate PCML document |
|
tracein | boolean | Trace input parameters Boolean flag to specify the requirement to print input parameters in job log. If true, all input parameters will be printed in session job log before performing call to program |
false |
traceout | boolean | Trace output parameters Boolean flag to specify the requirement to print output parameters in job log. If true, all output parameters will be printed in session job log after call to program |
false |
run_command API
It is required to obtain OAuth2 token with run_command scope to call IBM i commands. API run_command is available on Main Gate endpoint