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
Original Message:
Sent: Thu June 30, 2022 09:32 PM
From: Thi Minh Man Nguyen
Subject: Decompress Gzip response content from External Rest API through Automation Script
I am using the automation script to POST requests to Oracle Rest API Endpoint. With the response code success <300, I can parse the JSON response and get the value from that payload. However, the error response in the case of failing with response code >300, the Oracle API response with the gzip-compressed. I can not parse this to the JSON. I tried to decompress it, but it seems to not work.
I am using router.invoke to post the request.
response = String(router.invoke(map, jsonStr))
responseObject=JSONObject.parse(response) => occur an error
This is the response header:
Content-Type:application/vnd.oracle.adf.error+json
Content-Encoding:gzip
Is there any method to decompress this JSON payload? Please help me if you did it before.
Thanks
IBM Maximo Asset Management 7.6.1.0 Build 20180718-1141 DB Build V7604-01
------------------------------
Thi Minh Man Nguyen
------------------------------
#AssetandFacilitiesManagement
#Maximo
#MaximoIntegrationandScripting