M
mdanwarh
Guest
Hi, I have developed a small REST application using OpenEdge 11.6. (see screen shot below) getting the response successfully. Now, I am using the following code to consume this REST service, but I am getting the StatusCode as 200 and StatusReason "Forbidden". Can anyone help me in resolving this issue? Any help will be highly appreciable. Thanks in advance I have written this code using the following youtube video www.youtube.com/watch /*------------------------------------------------------------------------ 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. 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. oClient = ClientBuilder:Build():KeepCookies(CookieJarBuilder:Build():CookieJar):Client. oURI = NEW URI('http', 'ctsc00520904801.cts.com', 8810). oURI
ath = '/myOEABLWebAppService/postCustomer/'. oCredentials = NEW Credentials('Tomcat Application', 'tomcat', 'tomcat'). oRequest = RequestBuilder:Build('POST', oURI) :UsingCredentials(oCredentials) :usingBasicAuthentication(oCredentials) :acceptJson() :Request. oResponse = ResponseBuilder:Build():Response. oClient:execute(oRequest, oResponse). oResponse = ClientBuilder:Build():Client:Execute(oRequest). MESSAGE STRING(oResponse:StatusCode) SKIP oResponse:StatusReason VIEW-AS ALERT-BOX. /* IF oResponse:StatusCode <> 200 THEN DISPLAY "Request Error" + String(oResponse:StatusCode). ELSE CAST(oResponse:entity, JsonObject):WriteFile('response.json', TRUE). */ LOG FILE Content: [16/08/31@23:25:58.615+2300] P-005440 T-011016 1 4GL HTTPCLIB REQUEST: FILE= C:\OpenEdge\WRK\request-raw.txt [16/08/31@23:25:58.618+2300] P-005440 T-011016 1 4GL HTTPCLIB RESPONSE: FILE= C:\OpenEdge\WRK\response-data-received.txt [16/08/31@23:25:58.620+2300] P-005440 T-011016 1 4GL SOCKET CONNECT: -H ctsc00520904801.cts.com -S 8810 [16/08/31@23:25:58.621+2300] P-005440 T-011016 1 4GL SOCKET CONNECT: TIME(ms)=1 [16/08/31@23:25:58.621+2300] P-005440 T-011016 1 4GL SOCKET WRITE: TIME(ms)=0 [16/08/31@23:25:58.621+2300] P-005440 T-011016 1 4GL SOCKET WRITE: SIZE(b)=252 [16/08/31@23:25:58.623+2300] P-005440 T-011016 1 4GL SOCKET READ: AVAIL(b)=1049 [16/08/31@23:25:58.623+2300] P-005440 T-011016 1 4GL SOCKET READ: TIME(ms)=0 [16/08/31@23:25:58.623+2300] P-005440 T-011016 1 4GL SOCKET READ: SIZE(b)=1049 [16/08/31@23:25:58.623+2300] P-005440 T-011016 1 4GL HTTPCLIB CHUNK: NUM= 1 [16/08/31@23:25:58.623+2300] P-005440 T-011016 1 4GL HTTPCLIB CHUNK: SIZE(b)= 8192 [16/08/31@23:25:58.623+2300] P-005440 T-011016 1 4GL HTTPCLIB CHUNK: READ(b)= 1049 [16/08/31@23:25:58.668+2300] P-005440 T-011016 1 4GL SOCKET READ: COMPLETE= yes [16/08/31@23:25:58.668+2300] P-005440 T-011016 1 4GL SOCKET READ: ERROR= ? [16/08/31@23:25:58.668+2300] P-005440 T-011016 1 4GL SOCKET READ: TOTAL TIME(ms)=45 [16/08/31@23:25:58.671+2300] P-005440 T-011016 1 4GL HTTPCLIB EXTRACT ENTITY: ERROR = Progress.Json.JsonParserError_1318 [16/08/31@23:25:58.671+2300] P-005440 T-011016 1 4GL HTTPCLIB EXTRACT ENTITY: Response entity contains raw message body
Continue reading...
Continue reading...