ajCallWsRest function
Description
The ajCallWsRest function returns data from a REST web service on the internet or intranet.
Syntax
ajCallWsRest(url As String, [http_method], [body], [user_name], [password], [header], [content_type], [run_condition], [run_by_function_point_only])
Argument Name | Description |
---|---|
url (required) | Specify the URL of the web service call. |
http_method (optional) | Specify the HTTP method 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. 4 indicates a DELETE request. If you do not specify anything, the default value will always be “0”. |
body (optional) | Specify the body for HTTP calls from a range of cells. The range of cells can span across multiple rows and columns. Each row represents a break line and all the columns will be concatenated. If you do not specify anything, the default value will always be an empty string (“”). |
user_name (optional) | Specify the username to access the web service call if applicable. If you do not specify anything, the default value will always be an empty string (“”). |
password (optional) | Specify the password of the username to access the web service call if applicable. If you do not specify anything, the default value will always be an empty string (“”). |
header (optional) | Specify the HTTP header from a range of cells. The first column should contain a header field name. The second column should contain a header field value. If you do not specify anything, the default value will always be an empty string (“”). |
content_type (optional) | Specify the content type of the HTTP request to the web service call. If you do not specify anything, the default value will always be “application/json”. |
run_condition (optional) | The function will run when the value is TRUE. Otherwise, it will not run. If you do not specify anything, the default value will always be TRUE. |
run_by_function_point_only (optional) | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Run Function Point. If it equals TRUE, the function can be executed with Run Function Point (AlchemyJ toolbar \ Run Function Point) only. If you do not specify anything, the default value will always be TRUE. |
The function will return:
1) Content type: HTTP response body
2) Method: Within a cell / cell array
Example
Below is an example of a GET request in Postman.
Below is an example of GET request in the AlchemyJ Excel workbook.
As you can see from the above example, the calling of the ajCallWsRest function is successful and the result returned is the corresponding HTTP response body (same as Postman).
#VALUE! will be returned when there is an error in the usage of the function.