Postman Code Snippets Kotlin

ivansocket
Sat, 10 Aug 2019 14:43:03 +0000
Help Hub

Hello I am trying to transform a postman request that works to Kotlin language supported in Spring MVC where the same request doesn’t work, would be very gratefull if anyone could help me with this Issue.
Postman:
GET: https://X.X.X.X:6200/something_flow-2019-08-09/_search?size=100

with a Body-> raw:
{
“query”: {
“bool”: {
“filter”: [
{ “range”: { “timestamp”: { “gte”: “2019-08-09T06:00:00”,“lt”:“2019-08-09T07:00:00”}}}
]
}
}
}

The kotlin code I have done is this:
val forEntity_Flow = restTemplate.exchange(“https://X.X.X.X:6200/something_flow-$da/_search/?size=50&pretty=1”,
HttpMethod.GET, HttpEntity("{\r\n\“query\”: { \r\n \“bool\”: { \r\n \“filter\”: [ \r\n { \“range\”: { \“timestamp\”: { \“gte\”: \“2019-08-08T06:00:00\”,\“lt\”:\“2019-08-08T10:00:00\”}}} \r\n ]\r\n }\r\n }\r\n}", headers), ResultsFlow::class.java)

The code executes but the body that is used to filter timestamp values is “ignored”.
What should I do to make this work?
Thank you !

3 posts - 2 participants

Read full topic