post json body containing object
Opened this issue · 1 comments
I have a problem when using RestBuilder to post data containing json string:
I hope the server side could get the json result as below:
{"to":["u080859b6886c2269b28999fb9677535b"],"toChannel":"1383378250","eventType":"138311608800106203","content":{"contentType":1,"toType":1,"text":"HELLO"}}
My code is as below:
def resp = rest.post("http://localhost:8080/I-MSG_HUB/line/mockReceiving/?uid=WUREKA"){
header 'X-Line-ChannelToken', LINE_ACCESS_TOKEN
contentType "application/json; charset=UTF-8"
//json "${jsonbody}"
json {
to = ["u080859b6886c2269b28999fb9677535b"]
toChannel = "1383378250"
eventType = "138311608800106203"
content = {
contentType = "1"
toType = "1"
text = "HELLO I AM HERE"
}
}
}
But when my server get the json body, it looks like below:
[content:[toType:1, contentType:1], to:[u080859b6886c2269b28999fb9677535b], toChannel:1383378250, eventType:138311608800106203]
As you see, the item "content" is wrong. Besides, it loose item "text"
Can you help me to solve that problem ?
Thank you.
Check the rest of your code to see if you have a variable named text
. If you do, that might conflict with the word text in the DSL. If you rename your variable something else, text
should show up.