set http response status dinamically in mirth from destination channel

368 Views Asked by At

I'm using mirth v3.12.0 and I have set an http listener channel source that read some parameters from a query string, then with that paramters a query is created to get data from db. I can access the db and read all data: in the destination of the channel, set as channel writer I have a script in the transformer where I put all that info in a json and than all that message is taken to the output by resposeMap.

In the case of bad request I compose a diffetent json reporting the error: until here all goes well but now I have to change the default http status code from 200 to 400 bad request, buy I cannot succeded in defining dinamically that value.

In the transformation script of the destination I tried to write

    responseStatusCode = '400';
    channelMap.put('responseStatusCode', responseStatusCode);

and to put $(responseStatusCode) in Response Status Code box in the source page in order to get the value set in the destination transformation script but it seems to be ineffective. Can anyone help me please?

1

There are 1 best solutions below

0
Patrick Palmerini On

The error was in the way I passed the parameter: must be ${responseStatusCode} within curly brackets