SparkHttp

Provides access to a HTTP client object.

e.g.

var httpSender = Spark.getHttp("http://somehost");

setBasicAuth

signature setBasicAuth(string username, string password)

returns SparkHttp

Sets credentials to be used for Basic Auth

params

userName - the username to use

password - the password to use

example

Spark.getHttp(url).setBasicAuth("myusername", "mypassword");

setHeaders

signature setHeaders(JSON headers)

returns SparkHttp

Add custom header to the request

params

headers - A JSON object

example

Spark.getHttp(url).setHeaders({"X-Custom-header":"1234"});

get

signature get()

returns SparkHttpResponse

Perform a HTTP GET request

example

var response = Spark.getHttp(url).get();

postForm

signature postForm(JSON form)

returns SparkHttpResponse

Perform a HTTP POST using a JSON form object

params

form - the HTTP form data

example

Spark.getHttp(url).postForm(form);

postXml

signature postXml(XMLObject form)

returns SparkHttpResponse

Perform a HTTP POST using an XML form object

params

form - the HTTP form data

example

Spark.getHttp(url).postXml(xmlForm);

postJson

signature postJson(JSON form)

returns SparkHttpResponse

Perform a HTTP POST using a JSON form object

params

form - the HTTP form data

example

Spark.getHttp(url).postJson(jsonForm);

postString

signature postString(string data)

returns SparkHttpResponse

Perform a HTTP POST using a string

params

data - the HTTP POST data

example

Spark.getHttp(url).postString(data);

putForm

signature putForm(JSON form)

returns SparkHttpResponse

Perform a HTTP PUT using a JSON form object

params

form - the HTTP form data

example

Spark.getHttp(url).putForm(form);

putXml

signature putXml(XMLObject form)

returns SparkHttpResponse

Perform a HTTP PUT using an XML form object

params

form - the HTTP form data

example

Spark.getHttp(url).putXml(xmlForm);

putJson

signature putJson(JSON form)

returns SparkHttpResponse

Perform a HTTP PUT using a JSON form object

params

form - the HTTP form data

example

Spark.getHttp(url).putJson(jsonForm);

putString

signature putString(string data)

returns SparkHttpResponse

Perform a HTTP PUT using a string

params

data - the HTTP PUT data

example

Spark.getHttp(url).putString(data);

delete

signature delete()

returns SparkHttpResponse

Perform a HTTP DELETE request

example

var response = Spark.getHttp(url).delete();
Did this page help you? Please enter your feedback below. For questions about using this part of the platform, please contact support here