Request Method

Request method helps you securely call third party APIs from widgets. Using this API, you can prevent malicious users from trying to gain access to critical information, such as user credentials and APIKeys. The Request method calls are routed through proxies, hence it also supports Cross-origin Resource Sharing (CORS). Request method supports GETPOST, DELETE, and HTTP methods. You can also upload files using Request method.

Parameters

The argument of this API must be passed as an object containing the following parameters.

ParameterTypeDescription
url *StringURL of the third-party API.
The domain of the requestURL must be mentioned under the whiteListedDomain key in the plugin-manifest.
Example: "whiteListedDomain": ["https://www.example.com"].
type *String

HTTP methods supported: - GET, POST, DELETE,PUT and PATCH.

Note:If the request involves a patch method, the value of type must be POST and the value of headers must be { header-override : PATCH }.

headers *StringHTTP headers supported to be passed in the request.
postBody *StringRepresents entity body. This parameter, which must be passed as an object, is required for PATCH, POST, and PUT requests.If you are making a GET call, make the postBody as empty.
data Key that contains the data to be appended as queryParams to the URL.
connectionLinkName Key for authenticating the third-party domain. The value of this parameter must be the same as the one passed in the connectionLinkName value in the plugin manifest.
responseType Key that specifies the type of data the response must contain. Values allowed are: arraybuffer, blob, document, json, text, ms-stream, and empty string. If responseType is mentioned in the payload, the postBody and fileObj will not be considered.
fileObj Key that helps upload file objects to the third-party domain. The value of this key must be an array of objects containing the key and file parameters
includeContentBoolean (True/False)Key that helps to include the content bytes in the request.
contentParamNameStringKey that helps to specify the parameter name in which the content bytes needs to be added.
contentFormatString

Key that helps to specify in which format the content bytes needs to be added.

Supported formats: txt | zip | html | pdf | docx |rtf  

If this key is not passed, we will consider html format by default. 

style_format

style_format = inline

Key that helps to specify the style in which the content needs to be exported.

If this key is not passed, the content will be exported without any styles.

sendAsFileBoolean (True/False)

Key that helps to specify if the content needs to added in multipart file format or not.

If this key is not passed, the content will be added to post params or payload string.

Sample Request

Copiedlet options = {
                        method: 'GET',  //HTTP method
                        url: 'https://example.com/1/files', 
                        secure: true,
                        parameters: {},
                        headers: {},
                        connection: connectionName
                      };
WriterClient.request(options).then(function(response) {
                              console.log("response :: "+response);
                              }