Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Get HttpStatus in a response using EnsLib.HTTP.OutboundAdapter

Question
Kurro Lopez · Sep 19, 2022

Get HttpStatus in a response using EnsLib.HTTP.OutboundAdapter

Hi community,

I have to do a development that should to connect with a external REST API and it throws different HttpStatus and a body content with the description of the problem.

I'm using the following code:

set tSC = ..Adapter.SendFormDataArray(.tHttpResponse,"POST",tHttpRequest,,,URL)

If the external API responses throws a 400 Status (Bad Request)

the tSC values is an error status and the value of tHttpResponse is empty, so I'm not able to check what is the Status Code and the content.

tSC="0 "_$lb($lb(5002,"<WRITE>zSend+120^%Net.HttpRequest.1",,,,,,,,$lb(,"MYAPP",$lb("$^zSend+120^%Net.HttpRequest.1 +1","$^zSendFormDataArray+64^EnsLib.HTTP.OutboundAdapter.1 +1","$^zCallService+61^MyApp.BO.REST.Base.1 +1","$^zSearch+1^MyApp.BO.REST.Providor.1 +1","$^zMessageHandler+6^MyApp.BO.REST.Providor.1 +1","$^zMessageHeaderHandler+23^MyApp.BO.REST.Providor.1 +1","$^zOnTask+42^Ens.Host.1 +1","D^zStart+62^Ens.Job.1 +2","D^StartEnsembleJob+6^|""%SYS""|STU +1"))))/* ERROR #5002: Error de cache: <WRITE>zSend+120^%Net.HttpRequest.1 */

is there any way to get the HttpStatus of the request?

Best regards,

#REST API #Caché
Product version: IRIS 2021.1
$ZV: IRIS for Windows (x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:39:22 ED

Source URL:https://community.intersystems.com/post/get-httpstatus-response-using-enslibhttpoutboundadapter