How to pass bigger value in header parameter while executing rest web services

By | September 26, 2022

Sage X3 provides a feature of REST web services used for calling external or third party API’s. It can be used for integrating third party solution with sage X3.

For executing this API’s, Sage X3 uses ASYRRESTCLI library. This library gives access to functions used to perform outgoing REST web services. The function used for executing web service is “EXEC_REST_WS”. The requests with parameters can use this function for executing their REST web service but only for the parameters having length less than 255 characters.

Since the length of the parameters used to call a REST web service was limited to 255 characters, a new function, called “EXEC_REST_WSCLB” has been created in ASYRRESTCLI processing as of 2020R3(12.0.23) and V11P17. This function is defined with the PARAM and HEADER clob parameters, that is , it allows the user to use header and parameters with more than length of 255 characters which was limited in EXEC_REST_WS function.

Following is the snippet of syntax required for using EXEC_REST_WSCLB function :

##Declaration of variables used for executing REST Web service##

Local Clbfile HTTPMETHOD(0),RESHEAD(0),RESBODY(0),PARA(1),HEAD(1),DATA(0)

Local Char WEBSERNAME(255),SUBURL(255)

Local Integer RETVAL

WEBSERNAME = “SampleRestWebService”

HTTPMETHOD = “POST”

SUBURL=””

PARA=”{}”

HEAD='{“Accept-Charset”:”UTF-8″,”Accept”:”application/json”,”content-type”:”application/json”,”Authorization”:”Bearer ‘+TOKEN+'”, “Keep-Alive”:”timeout=1″,”Accepts-Version”:”V1″}’

DATA ='{}’

RETVAL=func ASYRRESTCLI.EXEC_REST_WSCLB(WEBSERNAME ,HTTPMETHOD ,SUBURL,PARA,HEAD,DATA, 0,””,RESHEAD, RESBODY)

#############################################

The parameters used for above functions are described below as follows :

Parameter 1 : WEBSERNAME

Data type : Char

Description : Name of the REST web service created

Parameter 2 : HTTPMETHOD

Data type : Clbfile

Description : HTTP methods can be used on any endpoints which map to application’s create,read,update and delete operations

HTTP methodCRUDAction
GETReadReturns requested data
POSTCreateCreates a new record
PUTUpdateUpdates an existing record
DELETEDeleteDeletes an existing record

Parameter 3 : SUBURL

Data type : Char

Description : It is a sub-URL that appends to the Main URL specified while creating REST web service in Sage X3.

Parameter 4 : PARA

Data type : Clbfile

Description : Attributes that can be used in URL parameters

Parameter 5 : HEAD

Data type : Clbfile

Description : Attributes that can be used in request header parameters

Parameter 6 : DATA

Data type : Clbfile

Description : Body of the request used in web service.

Parameter 7 : RESHEAD

Data type : Clbfile

Description : Header of the response in web service.

Parameter 8 : RESBODY

Data type : Clbfile

Description : Body of the response in the web service.

“RETVAL” is the variable used for executing EXEC_REST_WSCLB function using above parameters.

This blog helps us to solve problem when user wants to pass values of length greater than 255 characters in headers and parameters while executing REST web services in Sage X3.