With Flint's HTTP Connector, we can send HTTP requests and read HTTP responses efficiently.

With this document, we will be able to use and work with the HTTP Connector.

Features

  • Based on standardized HTTP protocol versions 1.0 and 1.1
  • HTTP methods - GET, POST, PUT, DELETE, HEAD & PATCH
  • Direct access to the response body and headers sent by the server
  • Efficiently read through the response body
  • Send request with proxy server configuration.
  • Ability to set timeouts for connector execution
  • Synchronous / Asynchronous execution of the Connector

Connector Configuration

No additional configuration is required for HTTP connector

Actions

GET

Retrieve information from the given server using a given URI.

Request parameters

ParameterDescriptionRequired
connector_nameName of the HTTP Connector to be configured.true
methodHttp Request Methods: GETtrue
urlURL to be queriedtrue
headersHTTP Request headers holding information about the http request to be made specified in key-value pairs in string format. Multiple headers must be separated by comma ( , )false
is-proxyIf request send with proxy or without proxyfalse
proxyProxy details like hostname,port and protocol
  • hostname : Hostname of proxy server
  • port : Port number of proxy server
  • protocol : Protocol of proxy server.
true if is-proxy field true
timeoutTimeout in milliseconds, taken by the connector to serve the http request. Default timeout is 60,000 msfalse

Response parameters

ParameterDescription
bodyHTTP Response body sent by the server: text, text/plain, application/json, application/javascript, application/xml, text/xml
headersHTTP Response headers holding information about the http response received.

Example


proxy =  @input.get("proxy")

response=@call.connector("my-http-connector")
              .set("method","GET")
              .set("url","http://httpbin.org/get")
              .set("headers","Cache-Control: no-cache")
              .set("is-proxy",true)
              .set("proxy", proxy)
              .set("timeout",10000)
              .sync

response_body=response.get("body")           #Response Body
response_headers=response.get("headers")     #Response Headers 

 

POST

Send data to the server.

Request parameters

ParameterDescriptionRequired
connector_nameName of the HTTP Connector to be configured.true
methodHttp Request Methods: POSTtrue
urlURL to be queriedtrue
bodyHTTP Request body to be sent to the server.true
headersHTTP Request headers holding information about the http request to be made specified in key-value pairs in string format. Multiple headers must be separated by comma ( , )false
is-proxyIf request send with proxy or without proxyfalse
proxyProxy details like hostname,port and protocol
  • hostname : Hostname of proxy server
  • port : Port number of proxy server
  • protocol : Protocol of proxy server.
true if is-proxy field true
timeoutTimeout in milliseconds, taken by the connector to serve the http request. Default timeout is 60,000 msfalse

Response parameters

ParameterDescription
bodyHTTP Response body sent by the server: text, text/plain, application/json, application/javascript, application/xml, text/xml
headersHTTP Response headers holding information about the http response received.

Example

 

proxy =  @input.get("proxy")
response=@call.connector("my-http-connector")
              .set("method", "POST")
              .set("url", "http://httpbin.org/pos")
              .set("body","Welcome to Flint !!")
              .set("headers",["Content-Type:text/plain"," Authorization: b7d03a6947b217efb6f3ec3bd3504582"])
              .set("is-proxy",true)
              .set("proxy", proxy)
              .set("timeout",10000)
              .sync
response_body=response.get("body")           #Response Body
response_headers=response.get("headers")     #Response Headers
response_json = @util.json(response_body)    #Convert response to JSON Object. You can also use @util.xml() for xml.
name = response_json.path("$.name")          #Apply JSON PATH to get info from JSON.

 

PUT

Replaces all current representations of the target resource with the uploaded content.

Request parameters

ParameterDescriptionRequired
connector_nameName of the HTTP Connector to be configured.true
methodHttp Request Methods: PUTtrue
urlURL to be queriedtrue
bodyHTTP Request body to be sent to the server.true
headersHTTP Request headers holding information about the http request to be made specified in key-value pairs in string format. Multiple headers must be separated by comma ( , )false
is-proxyIf request send with proxy or without proxyfalse
proxyProxy details like hostname,port and protocol
  • hostname : Hostname of proxy server
  • port : Port number of proxy server
  • protocol : Protocol of proxy server.
true if is-proxy field true
timeoutTimeout in milliseconds, taken by the connector to serve the http request. Default timeout is 60,000 msfalse

Response parameters

ParameterDescription
bodyHTTP Response body sent by the server: text, text/plain, application/json, application/javascript, application/xml, text/xml
headersHTTP Response headers holding information about the http response received.

Example

 

proxy =  @input.get("proxy")

response=@call.connector("my-http-connector")
         .set("method","PUT")
         .set("url","http://httpbin.org/put")
         .set("body","Have some suggestions for flint? We are listening !")
         .set("headers",["Content-Type:text/plain","Authorization: b7d03a6947b217efb6f3ec3bd3504582"])
         .set("is-proxy",true)
         .set("proxy", proxy)
         .set("timeout", 10000)
         .sync

response_body=response.get("body")           #Response Body
response_headers=response.get("headers")     #Response Headers 

 

DELETE

Removes all current representations of the target resource given by a URI.

Request parameters

ParameterDescriptionRequired
connector_nameName of the HTTP Connector to be configured.true
methodHttp Request Methods: DELETEtrue
urlURL to be queriedtrue
bodyHTTP Request body to be sent to the server.false
headersHTTP Request headers holding information about the http request to be made specified in key-value pairs in string format. Multiple headers must be separated by comma ( , )false
is-proxyIf request send with proxy or without proxyfalse
proxyProxy details like hostname,port and protocol
  • hostname : Hostname of proxy server
  • port : Port number of proxy server
  • protocol : Protocol of proxy server.
true if is-proxy field true
timeoutTimeout in milliseconds, taken by the connector to serve the http request. Default timeout is 60,000 msfalse

Response parameters

ParameterDescription
bodyHTTP Response body sent by the server: text, text/plain, application/json, application/javascript, application/xml, text/xml
headersHTTP Response headers holding information about the http response received.

Example

 

proxy =  @input.get("proxy")

response=@call.connector("my-http-connector")
              .set("method", "DELETE")
              .set("url", "http://httpbin.org/delete")
              .set("body", "Old age way of automating processes !")
              .set("headers", ["Content-Type:text/plain","Authorization: b7d03a6947b217efb6f3ec3bd3504582"])
              .set("is-proxy",true)
              .set("proxy", proxy)
              .set("timeout", 10000)
              .sync
response_body=response.get("body")           #Response Body
response_headers=response.get("headers")     #Response Headers

 

Connector request error handling

This is how success or failures can be handled for the connector requests within your Flintbit. This would help to take appropriate action if something failed.

if response.exitcode == 0               # 0 is success.
  puts "success"
  # take action in case of success
else                                    # non zero means fail
  puts "fail"
  puts "Reason:" + response.message     # get the reason of failure
  ## Take action in case of failure
end

On this page: