You are here: Using BML > Functions & Scripts > URL Access

URL Access

These functions involve accessing data from a URL.

Closedmakeurlparam()

Syntax: makeurlparam({'name ':"value "})

This function is equivalent to creating an ampersand (&) delimited string. URL functions can be used to extract real-time data from an external system. To build a URL that returns relevant data, use a URL variable to define the parameters the URL expects. The makeurlparam() function constructs the parameters which are used by other URL access functions.

Parameters:

# Parameter Data Type Description
1 'name' String The name of the parameter.
2 "value" String The value of the parameter.

Return Type: Ampersand delimited string

Example of makeurlparam():


Closedurldata()

Syntax: urldata(String url, String httpMethod, [Dictionary headers, [String parameters]])

Retrieves data from a URL using HTTP GET or POST depending on the parameter (see the makeurlparam function for formatting).

Parameters:

# Parameter Data Type Description
1 URL String A URL location.
2 httpMethod   Either GET or POST.
3 Dictionary headers String  
4 [String parameters] String  

Return Type: The function returns the value associated with the key. The key is the actual HTTP response to the urldata() function. These key:value associations are stored in the dictionary.

An example is shown in the table below.

Key Value
Status-Code 200 OK
Content-Type Application/Json
Message-Body Value

Example of urldata():

urldata("http://www.example.com", "GET");


Closedurldatabyget()

Syntax: urldatabyget(URL, url_param, default_value)

This function retrieves data from a URL address by the HTTP Get Method. It is used for RESTful Web Services and is faster than the POST method.

CPQ Cloud allows access to Image Server files through the File Attachment attribute and through the urlDataByGet() function, even when the Image Server is secure. You can upload a file to the File Manager and “read” its content in BML by using urlDataByGet().

An image uploaded to the File Manager can be accessed in the Document Engine through a File Manager reference, Hyperlink and External Link.

File attachments can be accessed in the Document Engine.

Integration Criteria Value
Size Varies, but generally small
Frequency Triggered during workflow
Format Passes arguments as a URL
Transmission Synchronization Synchronous

Parameters:

# Parameter Data Type Description
1 URL N/A The location of the data you are trying to access.
2 url_param Dictionary This represents the makeurlparams() parameters that you created.
3 default_value String This is the default value (or error message) displayed if the data cannot be accessed.

Return Type: String

Example of urldatabyget():


Closedurldatabypost()

Syntax: urldatabypost(URL, url_param, default_value)

This function retrieves data from a URL address by the HTTP Post Method.

This function passes parameters separately from the URL. It is useful when handling sensitive data and/or larger requests. It allows for encrypted requests. This is used for SOAP Web Services. For more information, see Using SOAP with BML.

Integration Criteria Value
Size Varies, but generally small
Frequency Triggered during workflow
Format Passes arguments as XML (generally)
Transmission Synchronization Synchronous

Best Practice is to use the File Manager to hold the form POST.

Parameters:

# Parameter Data Type Description
1 URL N/A The location of the data you are trying to access.
2 url_param Dictionary This represents the makeurlparam() parameters you created.
3 default_value String This is the default value (or error message) displayed if the data cannot be accessed.

Additional parameters

CPQ Cloud allows additional parameters that can be passed to urldatabypost to pass header values.

headers = dict("string");

put(headers, "SoapAction Key", "SoapAction Value");

return urldatabypost("https://cpluto.bigmachines.com/httpreceiver", "", "", headers);

Return Type: String

Example of urldatabypost():

As the function suggests, this information is not available.

Sample Request


Closedurldatabypostasync()

Syntax: urldatabypostasync((String url, String parameters, String defaultValue, String callbackActionVarName, [Dictionary headers, [Boolean returnErrorResponse]])

Custom HTTP headers can be applied by passing a Dictionary of Strings in the optional headers parameter.

Parameters:

# Parameter Data Type Description
1 url String The URL location of the data you are trying to access.
2 parameters String This is the default value (or error message) displayed if the data cannot be accessed.
3 defaultValue String This is the default value (or error message) displayed if the data cannot be accessed.
4 callbackActionVarName String  
5 [Dictionary headers,]    
6 [returnErrorResponse]] Boolean Optional: The value response, based on the key specified in the dictionary.
  1. On success, the function returns the response String.
  2. If the function fails and the optional returnErrorResponse parameter is set to True, the function returns a specific HTTP error code message.
  3. Otherwise, the function returns the defaultValue.

A Request Soap Message should contain $_BM_ASYNC_ADDRESSING_TOKEN$ in the header.

Return Type: String

Examples of urldatabypostasync():

urldatabypostasync("http://www.example.com", "a1=v1&a2=v2", "error message", "callbackActionVarName");

urldatabypostasync("http://www.example.com", "a1=v1&a2=v2", "error message", "callbackActionVarName", myHeaders); //Uses custom HTTP headers

urldatabypostasync("http://www.example.com", "a1=v1&a2=v2", "", "callbackActionVarName", dict("string"), true); //Uses the HTTP error code message (without custom headers)

urldatabypostasync("http://www.example.com", "a1=v1&a2=v2", "", "callbackActionVarName", myHeaders, true); //Uses both custom headers and the error code message


NOTES

RELATED TOPICS

Related Topics Link IconSee Also