[progress Communities] [progress Openedge Abl] Forum Post: Re: Calling Rest Services Using...

  • Thread starter Thread starter mdanwarh
  • Start date Start date
Status
Not open for further replies.
M

mdanwarh

Guest
I am getting response now . The issue was 1) the URI Path was wrong. It should be oURI:Path = '/rest/myOEABLWebAppService/postCustomer/'. 2) I was not able to pass the input json. Now the updated code looks like below : /*------------------------------------------------------------------------ File : getProperties.p Purpose : Syntax : Description : Author(s) : Created : Wed Mar 30 13:25:00 IST 2016 Notes : ----------------------------------------------------------------------*/ /* *************************** Definitions ************************** */ BLOCK-LEVEL ON ERROR UNDO, THROW. /* ******************** Preprocessor Definitions ******************** */ /* *************************** Main Block *************************** */ USING OpenEdge.Net.HTTP.*. USING OpenEdge.Net.URI. USING Progress.Json.ObjectModel.JsonObject. USING Progress.Json.ObjectModel.JsonArray. LOG-MANAGER:LOGFILE-NAME = "C:/OpenEdge/WRK/request-log1.txt". LOG-MANAGER:LOGGING-LEVEL=5. DEFINE VARIABLE oClient AS IHTTPClient NO-UNDO. DEFINE VARIABLE oURI AS URI NO-UNDO. DEFINE VARIABLE oCredentials AS Credentials NO-UNDO. DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO. DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO. DEFINE VARIABLE oCookies AS Cookie NO-UNDO. DEFINE VARIABLE vlcRequestData AS LONGCHAR NO-UNDO. DEFINE VARIABLE oJsonParam AS JsonObject NO-UNDO. DEFINE VARIABLE oJsonParam1 AS JsonObject NO-UNDO. DEFINE VARIABLE oJsonDataArr AS JsonArray NO-UNDO. oClient = ClientBuilder:Build():KeepCookies(CookieJarBuilder:Build():CookieJar):Client. oURI = NEW URI('http', 'ctsc00520904801.cts.com', 8810). /*oURI:Path = '/myOEABLWebApp/rest/myOEABLWebAppService/postCustomer/'.*/ /*oURI:Path = '/myOEABLWebApp/rest/WebApp2Service/postCustomer/'.*/ oURI:Path = '/rest/myOEABLWebAppService/postCustomer'. /*oCredentials = NEW Credentials('Tomcat Application', 'tomcat', 'tomcat').*/ oJsonParam = NEW Progress.Json.ObjectModel.JsonObject(). oJsonParam:add("userId" , "ahussain"). oJsonParam:add("password" , "P@ssw0rD"). oJsonParam:add("whereClause" , " Customer.CustNum 200 THEN DISPLAY "Request Error" + String(oResponse:StatusCode). ELSE CAST(oResponse:entity, JsonObject):WriteFile('c:\OpenEdge\WRK\response.json', TRUE).

Continue reading...
 
Status
Not open for further replies.
Back
Top