Hi all.
We’re migrating email submittals to a http based service, which takes a JSON body in a POST request.
One of the fields in the post body is “emailBody”, which can be text or html.
So I’m attempting to use a JSONTemplater to build this, but it fails:
JSONTemplater (XMLTemplaterFactory): All features received
JSONTemplater (XMLTemplaterFactory): The following error occurred near line 7, column 50 of the query:
JSONTemplater (XMLTemplaterFactory): invalid expression: syntax error, unexpected "QName", expecting "," or "}"
An error has occurred. Check the logfile above for details
Translation FAILED with 1 error(s) and 4 warning(s) (0 feature(s) output)
Line 7 in the ROOT expression is the HTML, with escaped apostrophes and removed linefeeds and whitespace between tags:
{
"emailFromId": "planinfo@lifa.dk", "emailFromName": "planinfo@lifa.dk"
,"emailAddresses": e{fme:process-features("TO")}]
,"emailCcToId": "","emailCcToName": ""
,"emailBccToId": "","emailBccToName": ""
,"emailSubject": "TEST planinfo 2025"
,"emailBody": " <html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><title>PlanInfo Service 2025-09-03</title><link href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css\" rel=\"stylesheet\"></head><body> ...... </body></html>"
,"zipAttachments": true
,"groupAttachments": true
,"groupedContentName": "ZippedAttachments"
,"attachments": m{fme:process-features("ATTACHMENT")}]
,"attachmentStreams": r]
}
The JSON is valid (without the “fme:process-feature()”), and JSONTemplater works just fine if I remove the value for “emailBody”.
I suspect the problem lies with the embedded use of “XMLTemplaterFactory” mentioned in the error messages, as it errs on the first escaped apostrophe.
I’ve tested it in 2025.1.1, and the problem remains.
Cheers.