Hello Community!
We have this json payload for an api request we are making.
{
"fromDirectAddress" : "john@meda.com",
"toDirectAddress" : "smith@domain.com",
"emailAttachmentList" : [
{
"attachmentClass" : "application/xml",
"attachmentContent" : "PHRlc3Q+TWVkQWxsaWVzPC90ZXN0Pg==",
"attachmentTitle" : "MR-Lumbar Spine without contrast_1",
"attachmentFileName" : "ClinicalDocument"
},
"messageId" : "urn:uuid:a2d59543-91f4-45a4-99ef-72d70da1e454"
}
I created two classes (see below) but I am having issues with setting the emailAttachmentList as an array.
Class Request.SendDirectMessageRequest Extends (%Persistent, %XML.Adaptor, %JSON.Adaptor)
{
Parameter %JSONNULL = 1;
Property fromDirectAddress As %String(%JSONFIELDNAME = "fromDirectAddress", MAXLEN = "");
Property toDirectAddress As %String(%JSONFIELDNAME = "toDirectAddress", MAXLEN = "");
Attempt 1 // Property emailAttachmentList As Request.EmailAttachment(%JSONFIELDNAME = "emailAttachmentList");
Attempt 2 // Property emailAttachmentList As List of Request.EmailAttachment(%JSONFIELDNAME = "emailAttachmentList");
Property messageId As %String(%JSONFIELDNAME = "messageId", MAXLEN = "");
Property xdm As %Boolean(%JSONFIELDNAME = "xdm");
}
Class Request.EmailAttachment Extends (Ens.Request, %JSON.Adaptor)
{
Parameter %JSONIGNOREINVALIDFIELD = 1;
Property attachmentFileName As %String(%JSONFIELDNAME = "attachmentFileName", MAXLEN = "");
Property attachmentTitle As %String(%JSONFIELDNAME = "attachmentTitle", MAXLEN = "");
Property attachmentClass As %String(%JSONFIELDNAME = "attachmentClass", MAXLEN = "");
Property attachmentContent As %String(%JSONFIELDNAME = "attachmentContent", MAXLEN = "");
}
Attempt 1 (highlighted in yellow in the Request.SendDirectMessageRequest class) gives us the error below but at least that’s a response back as the message does leave IRIS.
Error HttpResponse: {"error":"/emailAttachmentList expected type: JSONArray, found: JSONObject"}
Attempt 2 gives us this error and the message doesn’t make it past the router.
ERROR <Ens>ErrBPTerminated: Terminating BP APIRouter1 # due to error: ERROR <Ens>ErrException: <PROPERTY DOES NOT EXIST>zS4+9^FAIS.BPL.APIBPL.Thread1.1 *attachmentClass,%Collection.ListOfObj -- logged as '-' number - @' Set status=1,callrequest.emailAttachmentList.attachmentClass="application/xml"'
> ERROR <Ens>ErrException: <PROPERTY DOES NOT EXIST>zS4+9^FAIS.BPL.APIBPL.Thread1.1 *attachmentClass,%Collection.ListOfObj -- logged as '-' number - @' Set status=1,callrequest.emailAttachmentList.attachmentClass="application/xml"'
Please assist us to figure out what we need to change the code to. Thank you!