call api
Mon Feb 26 2024 07:56:47 GMT+0000 (Coordinated Universal Time)
Saved by @MinaTimo
internal final class COATest
{
/// <summary>
/// Class entry point. The system will call this method when a designated menu
/// is selected or when execution starts and this class is set as the startup class.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
NW_MainAccountTb NW_MainAccountTb;
select NW_MainAccountTb where NW_MainAccountTb.NW_AutomatedID=="COAR-000123";
if(NW_MainAccountTb.RequestType == RequestType::Creation && NW_MainAccountTb.CreateInGLX==NoYes::Yes)
{
RetailWebRequest webRequest;
RetailWebResponse response;
RetailCommonWebAPI webApi;
NW_COAContractClass Contract;
str URL,json;
webApi = RetailCommonWebAPI::construct();
URL =NW_AutomatedParameters::find().COAAPIURL;// "https://apxuat.sanabil.com:1002/GLXCOA/Create";
info(URL);
str accountType = NW_AccountTypeHelper::AccountTypeMapping(NW_MainAccountTb.Type);
info(accountType);
if(URL && accountType)
{
Contract = new NW_COAContractClass();
Contract.entityName(LedgerChartOfAccounts::find(NW_MainAccountTb.LedgerChartOfAccounts).Name);
Contract.glxAccount(NW_MainAccountTb.New_MainAccount);
Contract.accountType(accountType);
Contract.description(NW_MainAccountTb.Name);
json = FormJsonSerializer::serializeClass(Contract);
str authHeader;
info(json);
response = webApi.makePostRequest(URL,json,authHeader,"application/json");
if(response.parmHttpStatus()!=200)
{
str result = response.parmdata() != "" ? response.parmdata() : strFmt("%1",response.parmHttpStatus()) ;
Error(result);
}
}
}
}
}



Comments