executeActivity
Call Signature¶
executeActivity(
uipath:IUiPath,connectionId:string,objectName:string,method?:ExecuteMethod,options?:ExecuteActivityOptions):Promise<ExecuteActivityResult>
Experimental
Run a connector activity: one operation on a connector object, through a connection.
Does what execute does and adds what a connector activity needs: body keys given as paths, file upload and download, paging, and query parameters that take a URL.
Warning
Preview: This function is experimental and may change or be removed in future releases.
A write (POST, PUT, PATCH) sent without a body carries an empty JSON object, and a file
response is returned as a Uint8Array.
Unlike standard SDK methods, this does not throw on non-2xx responses.
The full HTTP envelope (ok, status, body, headers) is returned so
callers can surface connector-specific error bodies.
When an admin remapped this connection id at deployment, the call targets the connection it was mapped to.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
uipath |
IUiPath |
UiPath SDK instance providing authentication and configuration |
connectionId |
string |
Connection GUID |
objectName |
string |
Connector object name (e.g. tickets, messages) |
method? |
ExecuteMethod |
HTTP method (defaults to GET) |
options? |
ExecuteActivityOptions |
Body, query params, files, paging (maxRecords), folder scoping (folderId / folderKey / folderPath), and robustness knobs (retry, timeoutMs, signal) |
Returns¶
Promise<ExecuteActivityResult>
Promise resolving to an ExecuteActivityResult
Examples¶
import { UiPath } from '@uipath/uipath-typescript/core';
import { executeActivity } from '@uipath/uipath-typescript/connections';
const sdk = new UiPath(config);
await sdk.initialize();
// GET — list records
const result = await executeActivity(sdk, '<connectionId>', 'tickets', 'GET');
if (result.ok) {
console.log(result.body);
} else {
console.error(`Connector returned ${result.status}: ${JSON.stringify(result.body)}`);
}
// POST — create a record
const result = await executeActivity(sdk, '<connectionId>', 'tickets', 'POST', {
body: { subject: 'New ticket', priority: 'high' },
});
// GET with query params and folder scoping — folderId and folderPath work too
const result = await executeActivity(sdk, '<connectionId>', 'tickets', 'GET', {
queryParams: { limit: '10', status: 'open' },
folderPath: 'Shared/Finance',
});
// One page at a time: `page` is set while the connector has more records
const first = await executeActivity(sdk, '<connectionId>', 'tickets', 'GET');
if (first.page?.hasMore) {
const second = await executeActivity(sdk, '<connectionId>', 'tickets', 'GET', {
queryParams: { nextPage: first.page.nextPageToken },
});
}
// Or let the call follow the pages: up to 250 records, or every record with -1
const tickets = await executeActivity(sdk, '<connectionId>', 'tickets', 'GET', { maxRecords: 250 });
// Upload a file. The body travels as a JSON part next to it.
const uploaded = await executeActivity(sdk, '<connectionId>', 'files', 'POST', {
files: [{ name: 'file', content: fileBytes, fileName: 'report.pdf', contentType: 'application/pdf' }],
body: { title: 'Quarterly report' },
});
// Download a file: `body` is a Uint8Array
const download = await executeActivity(sdk, '<connectionId>', 'files/<fileId>/content', 'GET', {
fileResponse: true,
});
// Retry transient connector failures. Retrying is off unless `maxRetries` is set.
const result = await executeActivity(sdk, '<connectionId>', 'tickets', 'GET', {
timeoutMs: 10_000,
retry: {
maxRetries: 3,
initialDelayMs: 500,
backoffStrategy: 'exponential',
backoffFactor: 2,
retryableStatusCodes: [429, 500, 502, 503, 504],
},
});
// A connector of version 4 or later: pass its version and key. `objectName` names the script.
const sent = await executeActivity(sdk, '<connectionId>', 'SendMessageToChannel', 'POST', {
connectorVersion: '4.0.0',
connectorKey: 'uipath-salesforce-slack',
queryParams: { send_as: 'bot' },
body: { channel: '<channelId>', messageToSend: 'Hello' },
});
// POST is not retried by default — a replay can create the same record twice.
// Opt in only when the connector operation is safe to repeat.
const result = await executeActivity(sdk, '<connectionId>', 'tickets', 'POST', {
body: { subject: 'New ticket' },
retry: { maxRetries: 2, retryMethods: ['POST'] },
});
Call Signature¶
executeActivity(
uipath:IUiPath,connection:ConnectionResource,objectName:string,method?:ExecuteMethod,options?:ExecuteActivityOptions):Promise<ExecuteActivityResult>
Experimental
Run a connector activity through a connection declared in uipath_resources.ts.
Warning
Preview: This function is experimental and may change or be removed in future releases.
When an admin remapped the connection at deployment, the call targets the connection it was mapped to, in that connection's folder, even when a folder option is passed. Like the id form, this does not throw on non-2xx responses.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
uipath |
IUiPath |
UiPath SDK instance providing authentication and configuration |
connection |
ConnectionResource |
Handle created with resource.connection() from @uipath/uipath-typescript/resources |
objectName |
string |
Connector object name (e.g. tickets, messages) |
method? |
ExecuteMethod |
HTTP method (defaults to GET) |
options? |
ExecuteActivityOptions |
Body, query params, files, paging (maxRecords), folder scoping (folderId / folderKey / folderPath), and robustness knobs (retry, timeoutMs, signal) |
Returns¶
Promise<ExecuteActivityResult>
Promise resolving to an ExecuteActivityResult
Example¶
// uipath_resources.ts
import { resource } from '@uipath/uipath-typescript/resources';
export class ProjectResources {
static readonly helpdesk = resource.connection({ id: '<connectionId>', connector: 'uipath-zendesk' });
}
// anywhere in the project
import { executeActivity } from '@uipath/uipath-typescript/connections';
const result = await executeActivity(sdk, ProjectResources.helpdesk, 'tickets', 'GET');