How to pass mongodb record to http client post as valid JSON
I have a mongoDB origin (not oplog, the regular one), followed by a Http Client (Processor). The goal is to read every JSON document from the mongodb, and for each one, call a REST service.
The rest service works, I can test that separately with Postman, and get proper results. I put the 'http method' to POST, and for the request body enter ${record:value('/')}. I leave Default Request Content Type as 'application/json'.
On the receiving end, I do get the entire record, but not as a valid json. My REST service shows that what I receive is something like this:
[Field[MAP:{key1=Field[LIST:[key2=Field[MAP:{key3=Field[STRING:value1]}]]], key4=Field[LIST:[Field[MAP:{key5=Field[LIST:[Field[MAP:{key6=Field[STRING:value2]}]]]}]]]}]]
while it should be:
{ "key1": [{"key2": [{"key3": "value01"}], "key4": [{"key5": [ {"key6": "value02"}] }] }] }
How would I be able to pass a valid JSON ? I see 2 possibilities:
Is there something special I can put in http client - http request body (${record:value('/')}.toJson would be lovely)
Is there an processor I can put between my mongodb and http client that would transform it ?
Sorry for the lack of pics, too little points here.