Never done it, but it got me curious … I think the example in the doco is wrong for two reasons: it’s missing -X POST in the dynamic example, and the newline breaking in the middle of the json doesn’t work.
If you add -X POST and put the json string on one continuous line it works:
curl -X POST -H "X-Auth-Token: $LNMSAPI" "${APIPATH}devicegroups" \
-d \
'{"name": "New Device Group", "desc": "A very fancy dynamic group", "type": "dynamic", "rules": "{\"condition\":\"AND\",\"rules\":[{\"id\":\"access_points.name\",\"field\":\"access_points.name\",\"type\":\"string\",\"input\":\"text\",\"operator\":\"equal\",\"value\":\"accesspoint1\"}],\"valid\":true}"}'
If you want to break it up for readability, the best example of how to do this I’ve seen rather that complicated escaping or heredocs is this:
curl -X POST -H "X-Auth-Token: $LNMSAPI" "${APIPATH}devicegroups" \
--data-raw '
{
"name": "New Device Group",
"desc": "A very fancy dynamic group",
"type": "dynamic",
"rules": "{\"condition\":\"AND\",\"rules\":[{\"id\":\"access_points.name\",\"field\":\"access_points.name\",\"type\":\"string\",\"input\":\"text\",\"operator\":\"equal\",\"value\":\"accesspoint1\"}],\"valid\":true}"
}
'