Is Http post method available for SmartThings IDE?


#1

Hi Guys,

Just started This SmartThings development and groovy language today.
Is there any way to perform http post method?
I tried this on my app and i receive following error

  • error java.lang.NullPointerException: Cannot invoke method request() on null object @ line 60

    http.request(POST) {
    uri.path = 'http://www.test.com/handler.php
    body = [name: ‘bob’, title: ‘construction worker’]
    requestContentType = ContentType.JSON

    response.success = { resp ->
    println “Success! ${resp.status}”
    }

    response.failure = { resp ->
    println “Request failed with status ${resp.status}”
    }


(Brian Steere) #2

There is a method called httpPost that will do what you want http://docs.smartthings.com/en/latest/ref-docs/smartapp-ref.html?highlight=httppost#httppost


#3

Thanks a lot, that’s what i need :slight_smile: