#dim tResponse As HS.FHIRServer.Interop.Response
Set tSC = ..SendRequestSync(..TargetConfigName, tRequest, .tResponse)
if (($P(tResponse.Response.Status," ",1)>199) && ($P(tResponse.Response.Status," ",1)<399))
{ Set tResponseQuickStream = ##class(HS.SDA3.QuickStream).%OpenId(tResponse.QuickStreamId)
Set tSC = $$$ERROR($$$GeneralError, tResponseQuickStream.Read())
//Set BundleObject=##class(HS.FHIR.DTL.vR4.Model.Resource.Bundle).FromJSON(tResponseQuickStream,"vR4")
Set BundleObject=##class(%DynamicObject).%FromJSON(tResponseQuickStream)

}

if (($P(tResponse.Response.Status," ",1)>199) && ($P(tResponse.Response.Status," ",1)<399))
{
Set tResponseQuickStream = ##class(HS.SDA3.QuickStream).%OpenId(tResponse.QuickStreamId)
Set tSC = $$$ERROR($$$GeneralError, tResponseQuickStream.Read())
Set BundleObject=##class(HS.FHIR.DTL.vR4.Model.Resource.Bundle).FromJSON(tResponseQuickStream,"vR4")
Quit BundleObject
}

You can use the line similar to below instead of Bundle if you are unsure of the payload as well

BundleObject=##class(%DynamicObject).%FromJSON(tResponseQuickStream)

We sent the EnsLib.HTTP.GenericService into a process that did this, hope it helps.

Include Ensemble

Class Component.httpResendMessage Extends Ens.BusinessProcess
{

Method OnRequest(pRequest As EnsLib.HTTP.GenericMessage, Output pResponse As EnsLib.HTTP.GenericMessage) As %Status
{     

    set tSC=$$$OK
    namespace = $REPLACE(pRequest.HTTPHeaders.GetAt("IParams_1"),"namespace=","")
    ClientDocGUID= $REPLACE(pRequest.HTTPHeaders.GetAt("IParams_2"),"ClientDocGUID=","")
   

   s pResponse=##class(EnsLib.HTTP.GenericMessage).%New()
   set pResponseBody=##Class(%Stream.GlobalCharacter).%New()
   d pResponseBody.Write("<HTML><HEAD>Uh oh.</HEAD><BODY><BR><STRONG>Error: Invalid Patient ID</STRONG></BODY></HTML>")
   do pResponseBody.Rewind()
   d pResponse.HTTPHeaders.SetAt("HTTP/1.1 400 Bad Request","StatusLine")
   d pResponse.HTTPHeaders.SetAt("text/html; charset=utf-8","Content-Type")
   do pResponse.StreamSet(pResponseBody)
quit tSC
}  

}

You could also try adding a code section to you DTL, similar to this.

//this part collates the info to set the doctype
 set version=target.GetValueAt("MSH:VersionID.versionID")
 set type=target.GetValueAt("MSH:MessageType.messagetype")
 set trigger=target.GetValueAt("MSH:MessageType.triggerevent")
 //set trigger="A05"
 if ((trigger = "A08")!(trigger = "A11")!(trigger = "A27")!(trigger = "A03")!(trigger = "A12")!(trigger = "A13")){SET trigger = "A01"}
 //this sets the doctype
 set target.DocType=version_":"_type_"_"_trigger
 //set target.DocType="2.4:ADT_A05"