i'm trying to automatically deploy mirth with docker using curl commands to hit mirth client api from inside the freshly deployed container. I got the configuration map and channels to be correctly imported and deployed.
The issue i'm having is with importing the code templates themselves
i tried to do the following command:
curl --retry 3 --retry-connrefused --retry-delay 2 --insecure -u admin:admin -X PUT -H "accept: application/xml" -H "Content-Type: application/xml" -H "X-Requested-With: OpenAPI" https://$HOST:$PORT/api/codeTemplateLibraries -d "@$filename"
The file that i'm giving it is an xml that has all the code templates as a list, but this is importing only the code template libraries, but the code templates will be empty on mirth.
i found the following post that was helpful: Mirth Connect : Import Code Templates by REST API
so i tried the same approach to import code templates separately. It worked via postman but if i tried to add the the following command on a setup script:
curl --retry 3 --retry-connrefused --retry-delay 2 --insecure -u admin:admin -X PUT -H "accept: application/xml" -H "Content-Type: application/xml" -H "X-Requested-With: OpenAPI" https://$HOST:$PORT/api/codeTemplates/{code-template-id}?override=true -d @${DIR}/code-templates/codeTemplateName.xml
it is throwing the following error when it's trying to run the above command:
<detailMessage>Unable to save code template "codetemplateName": Error on line 2: missing } after function body (id-removed#2).</detailMessage>
mirth_1 | <cause class="org.mozilla.javascript.EvaluatorException">
mirth_1 | <detailMessage>missing } after function body</detailMessage>
mirth_1 | <stackTrace>
mirth_1 | <trace>org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:79)</trace>
mirth_1 | <trace>org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:66)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.addError(Parser.java:258)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.reportError(Parser.java:326)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.reportError(Parser.java:320)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.mustMatchToken(Parser.java:480)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.mustMatchToken(Parser.java:470)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.parseFunctionBody(Parser.java:771)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.function(Parser.java:926)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.function(Parser.java:858)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.parse(Parser.java:630)</trace>
mirth_1 | <trace>org.mozilla.javascript.Parser.parse(Parser.java:570)</trace>
mirth_1 | <trace>org.mozilla.javascript.Context.parse(Context.java:2533)</trace>
mirth_1 | <trace>org.mozilla.javascript.Context.compileImpl(Context.java:2482)</trace>
mirth_1 | <trace>org.mozilla.javascript.Context.compileString(Context.java:1486)</trace>
mirth_1 | <trace>org.mozilla.javascript.Context.compileString(Context.java:1475)</trace>
mirth_1 | <trace>com.mirth.connect.server.controllers.DefaultCodeTemplateController.updateCodeTemplate(DefaultCodeTemplateController.java:465)</trace>
mirth_1 | <trace>com.mirth.connect.server.api.servlets.CodeTemplateServlet.updateCodeTemplate(CodeTemplateServlet.java:132)</trace>
mirth_1 |
mirth_1 | <trace>java.base/java.lang.Thread.run(Thread.java:833)</trace>
mirth_1 | </stackTrace>
mirth_1 | <suppressedExceptions class="empty-list"/>
mirth_1 | <sourceName>id-removed</sourceName>
mirth_1 | <lineNumber>2</lineNumber>
mirth_1 | <lineSource>}</lineSource>
mirth_1 | <columnNumber>1</columnNumber>
mirth_1 | </cause>
Any help would be greatly appreciated thanks