ajWebServices function
Available since AlchemyJ v4.3 AlchemyJ Community Edition, AlchemyJ Enterprise Edition
Description
The ajWebServices function returns data from web service(s) on the internet or intranet. The response can span across multiple cells.
Syntax
ajWebServices(url list As String, [http_method list ], [body list],[header list],[cookie list] [user_name], [password], [content_type], [response_type],[include_header],[check_ssl_cert],[options],[run_condition], [run_by_function_point_only])
Argument Name | Argument Type | Description |
---|---|---|
url list (required) | Range | It is a range of cells to specify the URL list of the web service call. When there has some special characters in the url, you can also use the ENCODEURL function in conjunction with the ajWebServices function. For example, =ajWebServices("http://127.0.0.1:8080/stockorder/stock?name="&ENCODEURL("C1")), where you have a stock ticker in C1. If the value of C1 is "Ticker 01", the url will become http://127.0.0.1:8080/stockorder/stock?name=Ticker%2001 |
http_method list (optional) | Range | It is a range of cells to specify the HTTP method list to call the web service. 0 indicates a POST request. 1 indicates a GET request. 2 indicates a PUT request. 3 indicates a PATCH request. 5 indicates a OPTIONS request. 6 indicates a HEAD request. 7 indicates a TRACE request. The default value is 0. |
body list (optional) | Range | It is a range of cells to specify the body list for HTTP calls from a range of cells. The range of cells can span across multiple rows and columns. All the cells will be concatenated. The default value is an empty string (“”). |
header list (optional) | Range | It is a range of cells to specify the HTTP header list from a range of cells. The first column should contain a header field name. The second column should contain a header field value. The default value is an empty string (""). |
cookie list (optional) | Range | It is a range of cells to specify the HTTP cookie list from a range of cells. The first column should contain a cookie field name. The second column should contain a cookie field value The default value is an empty string (""). |
user_name (optional) | String | The username to access the web service call if applicable. The default value is an empty string (“”). |
password (optional) | String | The password of the username to access the web service call if applicable. The default value is an empty string (“”). |
content_type (optional) | String | The content type of the HTTP request to the web service call. The default value is “application/json”. |
response_type (optional) | Integer | It is a number value indicate which response type to be included. 0 - all body, header and cookie 1 - body only 2 - header only 3 - cookie only The default value is 1. |
include_header (optional) | Boolean | If it equals TRUE, the return value will include column headers. If it equals FALSE, the return value will not include column headers. The default value is FALSE. |
check_ssl_cert (optional) | Boolean | If it equals TRUE, the return value will include column headers. If it equals FALSE, the return value will not include column headers. The default value is FALSE. |
Options (optional) | Range | It is a range of cells to specify the options. The first column should contain a field name. The second column should contain a field value. The default value is an empty string (""). |
run_condition (optional) | Boolean | The function will run when the value is TRUE. Otherwise, it will not run. The default value is TRUE. |
run_by_function_point_only (optional) | Boolean | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Preview Function Point. If it equals TRUE, the function can be executed with Preview Function Point (AlchemyJ ribbon \ Preview Function Point) only. The default value is TRUE. |
The function will return:
1) Return Value: HTTP response body/header/cookie
2) Return Type: Single Value / Multiple values (array formula)
Error Scenarios
It will return #VALUE! when missing any required parameter or mismatch parameter type. Besides, system will raise error for below scenario(s).
Error Scenario |
---|
The API throw error. |
Failed to call the API. |
Invalid http method. |
Invaid reponse type. |