Skip navigation links

Package com.bosch.iot.dm.groovy.http

Provides API for HTTP Client in the IoT Manager scripting.

See: Description

Package com.bosch.iot.dm.groovy.http Description

Provides API for HTTP Client in the IoT Manager scripting. HTTP Client binding in Groovy is httpClient or hc.

Example usage:

 
   // define some basic http request
   def httpRequest = httpClient.buildHttpRequest(HttpMethod.GET, 'https://postman-echo.com/get?foo1=bar1&foo2=bar2');

   // you can add what you need in the request here:
   // httpRequest.putHeader('Content-Type','application/json')
   // httpRequest.timeout(6000)
   // etc...
   // here we define the async processing of the response
   Closure processResponse = {result,error ->
     if (error != null) {
       throw new Exception(error)
     }
     HttpResponse res = result as HttpResponse
     return 'http response code is:  ' + res.statusCode()
   }

   // and here you can send the request with response handling callback
   httpRequest.send(processResponse)
 
 
Skip navigation links