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.

About Us

Greytrix – a globally recognized and one of the oldest Sage Development Partners is a one-stop solution provider for Sage ERP and Sage CRM organizational needs. Being acknowledged and rewarded for multi-man years of experience and expertise, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development, and implementation competence.

Greytrix has some unique integration solutions developed for Sage CRM with Sage ERPs namely Sage X3Sage IntacctSage 100Sage 500, and Sage 300. We also offer best-in-class Sage ERP and Sage CRM customization and development services to Business Partners, End Users, and Sage PSG worldwide. Greytrix helps in the migration of Sage CRM from Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes addons like  Greytrix Business Manager, Sage CRM Project Manager, Sage CRM Resource Planner, Sage CRM Contract Manager, Sage CRM Event Manager, Sage CRM Budget Planner, Gmail Integration, Sage CRM Mobile Service Signature, Sage CRM CTI Framework.

Greytrix is a recognized Sage Champion Partner for GUMU™ Sage X3 – Sage CRM integration listed on Sage Marketplace and Sage CRM – Sage Intacct integration listed on Sage Intacct Marketplace. The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for the processing and execution of application programs at the click of a button.

For more information on our integration solutions, please contact us at sage@greytrix.com. We will be glad to assist you.