Uh oh! We couldn’t find any match.

Please try other search keywords.

Bixby Developer Center

Guides

http

Provides helper methods for HTTP requests.

Note

All calls in the HTTP module are made synchronously and will wait until a system-defined timeout. It is usually not appropriate to wrap HTTP calls from Bixby in promises or callbacks. All methods accept both HTTP and HTTPS (secure) URLs.

const http = require('http');

HTTP Options

The following HTTP methods all take an options argument:

The options argument is a JSON object that can contain the following parameters:

  • format: This specifies how the response will be processed. It may be one of 'text', 'json', 'xmljs', or 'csv'.
  • query: An object with attribute/value pairs to pass as arguments to the REST service.
  • basicAuth: HTTP Basic Authentication. The value must be an object with "username" and "password".
  • cacheTime: Cache time in milliseconds. By default, all GET requests are cached in memory. An alternate cache time may be provided.
  • headers: An object with key/value pairs for additional HTTP headers. This may be used for custom Content-Type settings (such as XML).
  • passAsJson (POST call only): If set to true, passes the request parameters in the body in JSON format and sets the content type appropriately.
  • returnHeaders: If set to true, returns HTTP headers and status code. This also suppresses exceptions on HTTP error status codes, leaving this to the developer to handle.

You can set headers information in the options parameter, like in the following example:

let options = {
format: 'json',
headers: {
'accept': 'application/json'
},
};

let response = http.getUrl('https://my-capsule.com/api/search/', options);

http.getUrl(url, options)

Perform an HTTP GET request. Returns a string.

Kind: Static method of http
Access: Public

ParamTypeDescription
urlString
optionsObjectSee HTTP options

http.postUrl(url, params, options)

Perform an HTTP POST request.

Kind: Static method of http

Supports all the options from getUrl(), plus the following:

  • passAsJson: If true, pass the request parameters in the body in JSON format.
ParamTypeDescription
urlString
paramsObjectUnencoded keys and values for the POST body
optionsObjectSee HTTP options

http.deleteUrl(url, params, options)

Perform an HTTP DELETE request.

Kind: Static method of http

Supports all the options from getUrl(), plus the following:

  • passAsJson: If true, pass the request parameters in the body in JSON format
ParamTypeDescription
urlString
paramsObjectUnencoded keys and values for the DELETE body
optionsObjectSee HTTP options

http.putUrl(url, params, options)

Perform an HTTP PUT request.

Kind: Static method of http

Supports all the options from getUrl(), plus the following:

  • passAsJson: If true, pass the request parameters in the body in JSON format
ParamTypeDescription
urlString
paramsObjectUnencoded keys and values for the POST body
optionsObjectSee HTTP options

http.oauthGetUrl(url, options)

Perform an HTTP GET request, signed with the OAuth appropriate access keys. (See Implementing JavaScript Actions for details.)

Kind: Static method of http
Access: Public

Supports the same options as getUrl().

ParamTypeDescription
urlString
optionsObjectSee HTTP options

http.oauthPostUrl(url, params, options)

Perform an HTTP POST request, signed with the OAuth appropriate access keys. (See Implementing JavaScript Actions for details.)

Kind: Static method of http
Access: Public

Supports the same parameters and options as postUrl().

ParamTypeDescription
urlString
paramsObjectUnencoded keys and values for the POST body
optionsObjectSee HTTP options

http.oauthDeleteUrl(url, params, options)

Perform an HTTP DELETE request, signed with the OAuth appropriate access keys. (See Implementing JavaScript Actions for details.)

Kind: Static method of http
Access: Public

ParamTypeDescription
urlString
paramsObjectUnencoded keys and values for the DELETE body
optionsObjectSee HTTP options

Supports the same parameters and options as deleteUrl().

http.oauthPutUrl(url, params, options)

Perform an HTTP PUT request, signed with the OAuth appropriate access keys. (See Implementing JavaScript Actions for details.)

Kind: Static method of http
Access: Public

Supports the same parameters and options as putUrl().

ParamTypeDescription
urlString
paramsObjectUnencoded keys and values for the PUT body
optionsObjectSee HTTP options

http.spsProxyPost(options)

Delivers an SPS payment via an HTTP POST request. For more information, see the Supporting Payments topic.

Kind: Static method of http

ParamType
optionsObject

In the capsule's local JavaScript, you should define the options parameter like the following:

var options = {}
options.headers = {
"Content-Type" : "application/json",
"request_num" : "1"
}
options.body = {
"heyTicketmasterCreateMyWallet": "just do it",
"card_number": "{{credit_card_number}}"
}
options.url = "https://postman-echo.com/post" // optional, can also be specified via `sps` in `endpoints`
var response = http.spsProxyPost(options)

http.spsProxyPut(options)

Delivers an SPS payment via an HTTP PUT request. For more information, see the Supporting Payments topic.

Kind: Static method of http

Supports the same parameters and options as http.spsProxyPost.

ParamType
optionsObject

http.makeQueryString(args)

Return a properly-formatted query string.

Kind: Static method of http
Access: Public

ParamType
argsObject

The object key-value pairs are used as the query parameter keys and values. Values will be URL-encoded. You can pass this object to http.makeQueryString():

{"color": "red", "flavor": "peppermint stick"}

The queryString returned is:

color=red&flavor=peppermint%20stick