The input for the function can be acquired in the following types
Parameters
Parameters are passed in URL of query string and the data passed in the post "form-data" section in an input. The "params" in the crmAPIRequest map contains these parameters which has all of the information that are passed in the request.
Sending parameters using POSTMAN, within the request URL
Sending parameters using POSTMAN, as JSON objects in form-data
Sending parameters using POSTMAN as keys in form-data
To get the additional parameters used in the request
- crmAPIRequestMap = crmAPIRequest.toMap();
- // to get the parameters of the request
- parameters = crmAPIRequestMap.get("params");
- /**
- Your Business Logic here
- **/
- return crmAPIRequestMap;
- Please
avoid using the name "arguments" as an argument within the function. As
the name mismatch might lead to some arguments not functioning.
- Mapping
of the arguments of the function is done automatically when passed
through "parameters", ie. passed through the Query String(of the URL) or
the form-data.
Stream
The "Body"
of the request can be used to get the content that is passed as a
stream to the request. Usually body is in use only when the request
method is POST.
Sending body using POSTMAN as a stream (raw)
Sending body using POSTMAN as a binary file
To get the entire body section of the request in a function
- crmAPIRequestMap = crmAPIRequest.toMap();
- // to get the Body content of the request
- request_body = crmAPIRequestMap.get("body");
- /**
- Your Business Logic here
- **/
- return crmAPIRequestMap;
In POSTMAN, the body content can be passed either in the raw or binary.
- If arguments of the function are passed through Stream, they will not mapped to the arguments of the function.
- In case you need to encode/decode the input data within the function, you can use the Encryption tasks available in Deluge.
File Content
If
the content type of the request is Multipart, it will be considered as a
file. You can get the file within the function in the request object.
The
file types currently supported are the text files. In order to send the
file to the function as a multipart data, send it under the argument
name "inputFile".
- crmAPIRequestMap = crmAPIRequest.toMap();
- // to get the File content of the request
- parameters = crmAPIRequestMap.get("file_content");
- /**
- Your Business Logic here
- **/
- return crmAPIRequestMap;
If input for the function are given as a "file", the arguments in the file will not mapped to the arguments of the function.
Headers
The
header of a request usually contains additional information about the
request. The information that is available in header can be acquired in
the "headers" key within the crmAPIRequest argument.
To get the headers of the request
- crmAPIRequestMap = crmAPIRequest.toMap();
- // to get the user info of the request
- header_request = crmAPIRequestMap.get("headers");
- /**
- Your Business Logic here
- **/
- return crmAPIRequestMap;
User Information
This
key can be used to get the information about the user, as well as the
organization of the user, who invokes the function using the OAuth2
method.
To get the info about the users
- crmAPIRequestMap = crmAPIRequest.toMap();
- // to get the user info of the request
- user_info = crmAPIRequestMap.get("user_info");
- /**
- Your Business Logic here
- **/
- return crmAPIRequestMap;
If the function is called as the API key, the user info that you get would be the info of the super admin and not the one who invokes the function.
Authentication Type and Method
These 2 keys can be used to get the authentication information (apikey or oauth) and the HTTP method (GET/POST).
To get the info about the authentication type
- crmAPIRequestMap = crmAPIRequest.toMap();
- // to get the HTTP method of the request
- user_info = crmAPIRequestMap.get("method");
- // to get the authentication type of the request
- user_info = crmAPIRequestMap.get("auth_type");
- /**
- Your Business Logic here
- **/
- return crmAPIRequestMap;