- Log in to post comments
set dynObj = {}.%FromJSON(Person.%ToJSON())- Log in to post comments
Something like this operation should do it for you.
Class Component.Outbound.JsonHttpsOut Extends Ens.BusinessOperation
{
Parameter ADAPTER = "EnsLib.HTTP.OutboundAdapter";
Property Adapter As EnsLib.HTTP.OutboundAdapter;
Method SendMessage(pMsgOut As %DynamicObject, Output pMsgIn As %Net.HttpResponse) As %Status
{
S tSC=$$$OK
Set tHttpRequest=##class(%Net.HttpRequest).%New(), tHttpRequest.WriteRawMode=1, token =##class(%DynamicObject).%New(), tSC=$$$OK
Set tHttpRequest.SSLConfiguration=..Adapter.SSLConfig
Set tSC = tHttpRequest.SetHeader("Content-Type", ..ContentType)
d tHttpRequest.EntityBody.Write(pMsgOut.%ToJSON())
#dim tHttpResponse As %Net.HttpResponse
Set tHttpResponse = ##class(%Net.HttpResponse).%New()
S send="POST"
Set tSC=..Adapter.SendFormDataArray(.tHttpResponse, send, tHttpRequest)
if (tHttpResponse.StatusCode="200"){
set message=tHttpResponse.StatusCode_": "_tHttpResponse.StatusLine_". "
if $IsObject(tHttpResponse.Data)
{
while 'tHttpResponse.Data.AtEnd {
set message=message_tHttpResponse.Data.Read(,.tSC1)
if 'tSC1 quit
}
$$$TRACE(message)
s tSC=$$$ERROR("9999",message)
}
s tSC=$$$OK
}
else
{
set message=tHttpResponse.StatusCode_": "_tHttpResponse.StatusLine_". "
if $IsObject(tHttpResponse.Data)
{
//set message=""
while 'tHttpResponse.Data.AtEnd {
set message=message_tHttpResponse.Data.Read(,.tSC1)
if 'tSC1 quit
}
$$$TRACE(message)
s tSC=$$$ERROR("9999",message)
}
Set ..Adapter.URL=$REPLACE(..Adapter.URL,..tmpurl,"") //sets adapter url back to standard if it was last used to remove an MRN
}
Q tSC
}
- Log in to post comments
I've written this, it still requires a bit of work for dealing with errors correctly as it does not yet use the reply action codes correctly.