Curl command to elasticsearch not working


#1

Hello, I have implemented a smartapp that writes events to elasticsearch.

Below is the snippet of the groovy code written on SmartThings IDE. I tested the curl command separately outside the SmartThings IDE, and it worked just fine. I also double checked that the sensors are continuing to produce events and my hub is capturing them correctly. However, the smartapp I implemented doesn’t seem to execute the curl command correctly. I don’t see any log messages either, so it is difficult to debug.
So, why am I not seeing anything on the log window? Does the curl command execution part contain any syntax error?

def installed() {
	log.debug "Installed with settings: ${settings}"       	
	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"
	unsubscribe()
	initialize()
}

def initialize() {
	subscribe (motion1, "motion", motionHandler)    
    subscribe (temperature1, "temperature", temperatureHandler)    
    subscribe (accel1, "acceleration", accelHandler)
    
}

// TODO: implement event handlers



def motionHandler() {
	// send evt.value to big data analyzer
    log.debug "Motion: ${evt.value}"    
    def response = ["curl", "POST", "http://some-address:9200/smartthings/motion", "-d", "{state:\"${evt.value}\"}"].execute().text
    
}

(Convinced ST will never be unbroken…) #2

CURL is not supported in SmartThings; you’ll have to use the httpPost.

https://graph.api.smartthings.com/ide/doc/smartApp


#3

Here is a curl statement that works just fine for writing data to elasticsearch:

curl POST "http://:9200/twitter/tweet -d ‘{state:“active”}’

I wrote following code to do the same that as the above command:

httpPostJson(uri: “http://<ip-address:9200/twitter/tweet”, body: {state: “${evt.value}”}) {response -> content = response.data}

Above code returns error saying that it is a bad request. httpPostJson example on http://docs.smartthings.com/en/latest/smartapp-developers-guide/calling-web-services-in-smartapps.html
shows that json body is enclosed within angle brackets instead of curly braces. Does smartthings replace the angle brackets with curly braces?
I did try the angle brackets, which messed up the mapping (schema) on elasticsearch index.
What exact httpPostJson call would be equivalent to the curl command I stated at the beginning?