Thanks for your help,
@MANU MAGANTIBut the
ScriptHTTPResp is available from 7.6.1.2. It doesn't exist in our version 7.6.1.0
I can get the response code by using the errorResponse.get("RESPONSE_STATUS"). I can not read the gzip compressed content response.
router = Router.getHandler("ENDPOINT")
map = HashMap()
errorResponse = HashMap()
errortext = HashMap()
map.put("ERRORONSTATUS",False)
map.put("RESPONSE_HEADERS",errorResponse)
map.put("RESPONSE_STATUS_TEXT",False)
response = String(router.invoke(map, jsonStr))
if int(errorResponse.get("RESPONSE_STATUS")) < 300:
responseObject=JSONObject.parse(response)
service.setWarning("MXOF","MESS",["The Item has been successfully created in external system", responseObject['ItemNumber']])
else:
responseObject=JSONObject.parse(response)
=> occur an error here because of the gzip compressed content service.error("MXOF","MESS",["Fail to integration ",responseObject['ErrorMessage']])
------------------------------
Thi Minh Man Nguyen
------------------------------
Original Message:
Sent: Wed July 06, 2022 10:02 AM
From: MANU MAGANTI
Subject: Decompress Gzip response content from External Rest API through Automation Script
Not sure if this will help, but take a look at this page. https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/integration/endpointhandler
I used processResponse(resp) to do this.
httpcode = resp.getResponseCode()
Check for httpcode > 300 and you can raise an exception.
------------------------------
MANU MAGANTI
EMA Canada| Inc.
OAKVILLE ON
------------------------------