CallWebService(BaseURL : Text;Method : Text;RestMethod : Text) : Text HttpClient := HttpClient.HttpClient(); HttpClient.BaseAddress := Uri.Uri(BaseURL); CASE RestMethod OF 'GET': BEGIN HttpResponseMessage := HttpClient.GetAsync(Method).Result; END; 'POST': BEGIN HttpResponseMessage := HttpClient.PostAsync(Method,HttpContent).Result; END; END; EXIT(FORMAT(HttpResponseMessage.Content.ReadAsStringAsync.Result));
Result := CallWebService(IntegrationSetup."URL", STRSUBSTNO('api/Books/UpdateSales?bookId=%1&sellingQuantity=%2',"Item No.","Qty. in stock", "Selling Source"),'POST'); IF UPPERCASE(Result) = API_RESPONSE THEN DELETE ELSE IF IntegrationSetup."Support Email" <> '' THEN BEGIN Email.CreateMessage('Sender Name',SMTPSetup."User ID",IntegrationSetup."Support Email",'Error in webservice', Result,FALSE); Email.Send; END;
IF NOT CALLWEBSERVICE() THEN BEGIN MESSGE(GETLASTOBJECTERROR); END;
Answers
This is how I solved it.
Instead of returing the response from the function i am processing it in that function.
and in the main i do like
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.