SmartThings Community

Unable to send json using variables

hello, i am trying to send a json req to a device i have
here is my function:

def post_to_dev(def dev_link, def dev_type, def dev_action)
{
log.debug “sending request to device: {dev_link} -> {dev_type}:{dev_action}" def params = [ uri: "{DeviceIP}:{DevicePort}/{dev_link}”,
body: ["{dev_type}" : "{dev_action}"]
]
try {
httpPostJson(params)
}
catch (e)
{
log.debug “something went wrong: $e”
}
}

When I run this I get always:
debug something went wrong: net.sf.json.JSONException: There is a cycle in the hierarchy!
debug sending request to device: tasks -> rgb_color:255.96.167
I have also tried things like
body: ["{dev_type}"&":"&"{dev_action}"]
OR
body: ["{dev_type}:{dev_action}"]
still getting the same results.
If though I replace with something like this:
body: [“something” : “a_value”]
it will work no problem.
Also same as
body: ["${dev_type}" : “a_value”]
will work too.
So the problem lies on the second variable.
What am I doing wrong/ or any suggestions on how to resolve this?
The function can change, all i wanna do is have a general function that sends anything I want as json
Thanks in advance for the help

Thanks for the reply, I saw this, not just sure how to apply it on the code I have attached…
Any help?