Still stuck on 11.7 on RHEL 8. Yes. I know. Sorry Tom. Migration to PASOE Webspeed is an absolute pain.
One of the side issues with 11.7 seems to be the flakiness of HTTP requests using the shipped classes. It works fine 95% of the time but then it gets a broken pipe. I've spoken in the past with Progress and the solution is to move to 12.2/8. In the meantime I'm having to change a bunch of REST interfaces to use cURL instead, but they don't want any of the functionality lost that was easy with HTTP requests.
I know that using -w I can get the HTTP Response code out on the command line, but I just can't work out how to capture that in my code. I need to get the payload into a file so I can parse it, but I also need to check the response code so I can handle the errors.
No matter what I do, cResult is blank. And I just can't work out how to get it to capture the http response code. When I run the cURL command on the command line I get the response output.
One of the side issues with 11.7 seems to be the flakiness of HTTP requests using the shipped classes. It works fine 95% of the time but then it gets a broken pipe. I've spoken in the past with Progress and the solution is to move to 12.2/8. In the meantime I'm having to change a bunch of REST interfaces to use cURL instead, but they don't want any of the functionality lost that was easy with HTTP requests.
I know that using -w I can get the HTTP Response code out on the command line, but I just can't work out how to capture that in my code. I need to get the payload into a file so I can parse it, but I also need to check the response code so I can handle the errors.
Code:
cFileName = RESTHelper:GetTempOutfile ().
cCurlCommand = SUBSTITUTE ("curl -X -sS --location --request GET &1 --header 'Content-Type: application/json' --header 'Authorization: Bearer &2' -o &3 -w '%~{http_code}'",
icURI,
icAuthentication,
cFileName).
INPUT STREAM sCurl THROUGH VALUE(cCurlCommand) NO-ECHO.
REPEAT:
ASSIGN cResult="".
IMPORT STREAM sCurl UNFORMATTED cResult.
END.
INPUT STREAM sCurl CLOSE.
message "cCurlCommand: " cCurlCommand skip "cResult: " cResult view-as alert-box.
COPY-LOB FROM FILE cFileName TO cJsonOutput CONVERT TARGET CODEPAGE "UTF-8".
oParser = NEW ObjectModelParser().
oResponseObject = CAST (oParser:Parse(cJsonOutput),JsonObject) NO-ERROR.
OS-DELETE VALUE (cFileName).
No matter what I do, cResult is blank. And I just can't work out how to get it to capture the http response code. When I run the cURL command on the command line I get the response output.