4.5.1 jp1Imdd.callRest
This method calls a REST API. The following table shows the details of the jp1Imdd.callRest method.
- Method name
-
Object jp1Imdd.callRest(String method, String url, Object headers, String body)
- Parameters
-
- method
-
A method of a REST API
- url
-
The URL of the REST API
When the URL including host name is specified, register the host name to the integrated manager's hosts file and DNS so as to enable name resolution on the integrated manager host. Configuration in jp1hosts file and jp1hosts2 file are not referred.
- _headers
-
The request header of the REST API
- body
-
The request body of the REST API
If the GET method is specified and the body is not needed, set body to null or an empty character.
- Return values
-
An object that stores the response from the REST API.
The object contains the following keys and values:
No.
Description
Key
Value
1
If the REST API is completed successfully
"response"
response object
Keys and values that are stored in the response object
"status"
HTTP status code
"headers"
response header
"body"
response body
2
If the analysis of the URI fails
"error"
error object
Keys and values that are stored in the error object
"status"
0
"body"
string indicating an analysis error
3
If the HTTP status code is 4xx or 5xx, or an unknown status code is returned
"error"
error object
Keys and values that are stored in the error object
"status"
HTTP status code
"headers"
response header
"body"
response body
- Exception
-
- RestClientException
-
-
When an I/O error occurs
-
- Call example
module.exports = function(args) { var baseUrl = args.baseUrl; var manager = args.manager; var jp1token = args.jp1token; var method = 'POST'; var apiPath = '/v1/authorization/token'; var url = baseUrl + apiPath; var headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-AJS-Authorization-Token': jp1token, }; var body = { parameters: { manager: manager, serviceName: 'AJSROOT1', } }; return jp1Imdd.callRest(method, url, headers, JSON.stringify(body)); }