S
Sivarami Reddy Marella
Guest
Dear Team, I am unable to read all the header values which are available in the rest service get method. The below is the piece of code I am trying. Especially I want read the bearer token as it is there in the attachment. I am getting only two values loop header 1 and loop header 2. (Procedure: 'geturl Vendor.p' Line:325) loop header 1 [18/07/18@09:08:22.250-0400] P-139392 T-124924 1 AS -- (Procedure: 'geturl Vendor.p' Line:325) Host [18/07/18@09:08:22.250-0400] P-139392 T-124924 1 AS -- (Procedure: 'geturl Vendor.p' Line:325) localhost:8080 [18/07/18@09:08:22.250-0400] P-139392 T-124924 1 AS -- (Procedure: 'geturl Vendor.p' Line:325) loop header 2 [18/07/18@09:08:22.250-0400] P-139392 T-124924 1 AS -- (Procedure: 'geturl Vendor.p' Line:325) User-Agent [18/07/18@09:08:22.250-0400] P-139392 T-124924 1 AS -- (Procedure: 'geturl Vendor.p' Line:325) OpenEdge-HttpClient/0.3.0 (WIN32/32) OpenEdge/11.5.1.0.1190 Lib-ABLSockets/0.3.0 DEFINE INPUT PARAMETER CVcode AS CHARACTER NO-UNDO. define variable cHostname as longchar. cHostname = System.Net.Dns:GetHostName(). message "cHostname" string(cHostname). DEFINE VARIABLE oLib AS OpenEdge.Net.HTTP.IHttpClientLibrary NO-UNDO. DEFINE VARIABLE oHttpClient AS OpenEdge.Net.HTTP.IHttpClient NO-UNDO. DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO. DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO. DEFINE VARIABLE oEntity AS Object NO-UNDO. DEFINE VARIABLE cURL AS CHAR NO-UNDO. DEFINE VARIABLE hXmlDoc AS HANDLE NO-UNDO. define variable oHeader as class OpenEdge.Net.HTTP.HttpHeader NO-UNDO. define variable oHeaderArray as class OpenEdge.Net.HTTP.HttpHeader extent NO-UNDO. define variable iHeaderCount as integer no-undo. define variable i-loop as integer no-undo . cURL = 'http://' + string(cHostname) + ':8080/Vendorinfo/rest/Vendorinfo/Vendorinfo/' + CVcode. message "cURL123" cURL. ASSIGN oLib = ClientLibraryBuilder:Build():sslVerifyHost(NO):library oHttpClient = ClientBuilder:Build():UsingLibrary(oLib):Client oRequest = RequestBuilder:Get(cURL):AcceptAll():Request oResponse = ResponseBuilder:Build():Response. message "error 456" error-status:error. oHttpClient:Execute(oRequest, oResponse). oEntity = oResponse:Entity. /* oHeader = oResponse:GetHeader('').*/ iHeaderCount = oRequest:GetHeaders(oHeaderArray). /* GetParameterValues ()*/ do i-loop = 1 to iHeadercount: MESSAGE "loop header" i-loop SKIP "" oHeaderArray[i-loop]:Name SKIP "" oHeaderArray[i-loop]:Value SKIP . if i-loop = iHeadercount then leave. end. IF TYPE-OF(oEntity, JsonObject) THEN CAST(oEntity, JsonObject):WriteFile('c:\temp\entity.json', true). ELSE DO: message "invalid json" . END. Thanks, Sivarami Reddy M
Continue reading...
Continue reading...