## Please enable JavaScript to view this site.

# Linkar Web Services 1.1.9

- Zoom Window Out
- Larger Text | Smaller Text
- Hide Page Header
- Show Expanding Text
- Print Topic
- Send Mail Feedback
- Share This Topic
- Save Permalink URL

Custom EndPoints | Scroll Prev Top Next More

LinkarWS allows to create custom EndPoints to execute any of the operations defined in the sendcommand function of Linkar Server.

They can be used to run CRUD requests, TCL/ECL commands, subroutines, and to format data.

More information at https://kosday.com/Manuals/en_WEB_LINKAR_Clients/lk_sendcommand.html

XML and JSON templates are available at https://github.com/kosday/Resources, to copy into the code and modify.

In this section we will include the necessary parameters to document the EndPoint in the Swagger and to execute the sendcommand function.

Field | Type | Description
New | Button | Create an EndPoint.
Delete Selected | Button | Deletes the selected EndPoints from the Database.
Export Selected | Button | Exports the selected EndPoints to a JSON file.
Import from file | Button | Import EndPoints from a JSON file.
Pencil Icon | Button | Edit the EndPoint.
Trash Can Icon | Button | Delete the EndPoint.
Copy Icon | Button | Create an EndPoint by copying data from an existing EndPoint.

Create/Edit/Copy EndPoint

Campo | Tipo | Descripción
Cancel | Button | Discard the changes and close the form.
Create/Update | Button | Save the EndPoint
Name | Required | Name of the EndPoint. Only numbers and letters. Will be used in the url to make the request.
Internal Description | Optional | Internal description for documentation.
EndPoint Description | Optional | This description will appear in the Swagger.
Enabled | Switch | Switch to enable or disable the EndPoint.
Input Arguments Description | Optional | We will indicate the meaning of the EndPoint arguments in each row. These comments will appear in the Swagger in documentary form. The label name assigned to each argument will appear in the box on the right, in the form %LKARGn% or %ESCAPED.LKARGn%.
Request Body Description | Optional | In case of needing to use the Body we will indicate here the description that will be used in the Swagger to document. The label to be used to assign the Body will be %LKBODY% or %ESCAPED.LKBODY%.
Request Body Example | Optional | We will use this property to document the Swagger with an example of the body.
Output Argument | Optional | It is a filter that allows to return to the client a part of the answer. If you do not specify anything, the complete result of the request will be returned. You can use these links to help you compose the expression: For JSON expressions: https://jsonpath.com/ For XML expressions: http://xpather.com/
Output Argument Description | Optional | A description of the output argument for documenting in Swagger.
HTTP status code argument number | Optional | It is the argument of the subroutine with the HTTS Error Code to be returned to the client. More info in HTTP status code
We must choose the template or templates of the sendcommand to be executed in this EndPoint. To do this we first define the type of command JSON or XML, and choose one of the templates available in the combo box. Click the Add Template button and the command structure will be painted in the Commands box. The possible labels to be used within the command are as follows: o%LKARGn% and %ESCAPED.LKARGn% n is a number from 1 to x. There are as many labels as you have parameters in endpoint. . ./api/v1/apidemo/custom/subroutine.demo?arg1=2&arg2=aa. %LKARG1% will be replaced by the value of arg1, and so on. The "ESCAPED" tag is used to replace escaped values. o%LKBODY% and %ESCAPED.LKBODY% If the endpoint is of the POST type where the input data must be in the Body of the request, we will use this tag to substitute it for the value contained in the Body o%LK.OUT:<expression>% This tag when you want to execute chained commands. LinkarWS allows us to execute a sequence of sendcommand type commands within the same custom endpoint. And this tag allows us to pass values from one response to the input of the next command. With an example it will be better understood: ../api/v1/apidemo/custom/demo.in.cascade?arg1=2&arg2=11 { "NAME" : "READ", "COMMAND" : { "CALCULATED" : "False" , "CONVERSION" : "False" , "FORMAT_SPEC" : "False" , "ORIGINAL_RECORDS" : "False" , "CUSTOM_VARS" : "" , "OUTPUT_FORMAT" : "JSON" , "FILE_NAME" : "LK.CUSTOMERS" , "DICT_CLAUSE" : "", "RECORDS" : [ { "LKITEMID" : "%LKARG1%" } ] } }, { "NAME" : "SUBROUTINE", "COMMAND" : { "SUBROUTINE_NAME" : "SUB.DEMOLINKAR" , "NUMBER_OF_ARGUMENTS" : "3" , "ARGUMENTS" : [ { "ARGUMENT" : "0" } , { "ARGUMENT" : "%LKOUT:COMMAND.RECORDS[0].NAME% - %LKARG2%" } , { "ARGUMENT" : "" } ] , "CUSTOM_VARS" : "" , "OUTPUT_FORMAT" : "JSON" } } The first command executes a READ of Register 2 of File LK.CUSTOMERS. The second command executes a SUBROUTINE, and one of its input arguments is the expression COMMAND.RECORDS[0].NAME which is extracted from the result of the first command.

Commands and Arguments

Through examples we will be able to explain how Custom Endpoints work. Based on the existing sendcommand templates, LinkarWS will receive the request and replace the parameters and/or body bodies in the template. In the following example using the url ../api/v1/apidemo/custom/subroutine.demo?arg1=2&arg2=aa the %LKARG1% tag will be replaced by the arg1 parameter and the %LKARG2% by the arg2 parameter. And linkar WS will return to the client the argument 3 of the subroutine In the following example the variable information of the request will come in the Body. You can view more examples by installing the apidemo configuration from the Dashboard.

Expression for the Output Argument

This property can be used to filter the result that arrives to the client. If no LinkarWS expression is used, it will return the complete result of the request. The format of the expressions to be used will depend on the OUTPUT_FORMAT parameter in all sendcommand templates. o"OUTPUT_FORMAT": "MV" The result will come in LkString format. More info at: https://kosday.com/Manuals/en_WEB_LINKARFRAMEWORKNETLIB/Lib_LinkarStrings/html/LkStrings.htm The first index of all the matrices used will always be 1. ARGUMENTS will return all the arguments of the subroutine ARGUMENTS[3] will return the third argument to the subroutine ARGUMENTS[0] is not a valid expression because in MV format it must start with 1. LinkarWS will return the complete result of the request. The expression TOTAL_RECORDS will return the value "101". The expression RECORD[1] will return the value "CUSTOMER 1þADDRESS 1þ444 - 444 - 001". The expression RECORD[1]<2> will return the value "ADDRESS 1". o"OUTPUT_FORMAT": "JSON" The result will be sent to the Client in JSON format. Any JsonPath expression can be used. A JSONPath expression specifies a path to an element (or a set of elements) in a JSON structure. You can use JSONPath Online Evaluator to validate your own expressions at https://jsonpath.com/ The first index of all the matrices used will always be 0. The expression COMMAND.ARGUMENTS[2] dewreturns the value "MY DOWNCASE TEXT". The expression COMMAND.TOTAL_RECORDS will return the value "101". The expression COMMAND.RECORDS[0] returns the json { "LKITEMID": "1", "NAME": "CUSTOMER 1", "ADDR": "ADDRESS 1", "PHONE": "444 - 444 - 001" } The expression COMMAND.RECORDS[0].NAME will return the value "CUSTOMER 1". o"OUTPUT_FORMAT": "XML" The result will be sent to the Client in XML format. Any XPath expression can be used. XPath uses path expressions to select nodes or node-sets in an XML document. These path expressions look very much like the expressions you see when you work with a traditional computer file system. You can use XPather to validate your own expressions at http://xpather.com/ The first index of all the arrays used will always be 1. /RESPONSE/ARGUMENTS/ARGUMENT[3] will return <RESPONSE>MY DOWNCASE TEXT</RESPONSE>

by Kosday Solutions