Invoke URL
Purpose
This command can be used to invoke any URL of your choice with the required authentication.
Request URL
clientsdk.dispatch("invokeUrl", {xhrObj:{url: , type: , headers: , payload: , serviceName: , params: , fileData: , file:{ fileName: , fileParamName: }, attachPayload: }})
Request Parameters
Parameter | Description | Value type |
url | The API URL you wish to invoke. Note: To invoke a URL, its domain must be included in the list of whiteListedDomains beforehand. | String |
type | Type of request. | String (Uppercase) Eg: GET |
headers | Headers that need to be included. | JSON |
payload | The payload that needs to be included. | JSON |
serviceName | Service name that is involved. It should be the same as the Connector created for this application. | String |
params | Request params that need to be sent. | JSON |
fileData | The desktop file attachment that needs to be uploaded. | BLOB |
fileName | Name of the file that has to be uploaded. | JSON |
fileParamName | Parameter name in which the file should be sent. | JSON |
attachPayload* | Request body that needs to be sent with the file . | JSON |
* only needed for file upload
Sample Request
Copiedclientsdk.dispatch("invokeUrl", {xhrObj: {url:"https://api.github.com/users/sample", type:"GET", params:{}, headers:{"Content-Type":"application/json"}, file:{"fileName":"sample.png","fileParamName":"File"}, attachPayload:{}, fileData: , payload:{}, charset: "UTF-8"}}).then(function(successResponse){console.log(successResponse)}, function(errorResponse) {console.log(errorResponse);})
Note:
To invoke this sample URL, "https://api.github.com/users/sample", ensure the domain "https://api.github.com" is already added to the list of whiteListedDomains.