Please enable JavaScript to view this site.

Navigation: LinkarWS Manager

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

 

Expression for the Output Argument