-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8.resumeTask.js
More file actions
65 lines (54 loc) · 2.39 KB
/
8.resumeTask.js
File metadata and controls
65 lines (54 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Description:
* Resume a paused workflow task and continue execution from where it left off.
* This operation is only available for tasks that are currently in a paused state - other status tasks cannot be resumed.
*
* Documentation:
* https://www.browseract.com/reception/integrations/api-workflow
*
* curl -X PUT 'https://api.browseract.com/v2/workflow/resume-task?task_id=1234567890' -H 'Authorization: Bearer app-abcdefghijklmn'
*/
const https = require('https');
function main() {
// API Key Required for API Call, generated from: https://www.browseract.com/reception/integrations
const authorization = "app-abcdefghijklmn";
// The task ID, returned by endpoints like /run-task.
// Please refer to "1.runTask.js"
const taskId = 1234567890;
try {
const options = {
hostname: 'api.browseract.com',
port: 443,
path: `/v2/workflow/resume-task?task_id=${taskId}`,
method: 'PUT',
headers: {
'Authorization': `Bearer ${authorization}`
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
if (res.statusCode === 200) {
// success example: No content will be returned
console.log('api-call-ok:', responseData);
} else {
// error example:
// {"code": 401, "msg": "Invalid authorization", "data": null, "ts": 1759917250113, "time": "2025-10-08 09:54:10", "traceId": "bcdef"}
// {"code": 10112, "msg": "Task is not exist.", "data": null, "ts": 1759918566040, "time": "2025-10-08 10:16:06", "traceId": "cdefg"}
// {"code": 10127, "msg": "Task resume only use for paused task", "data": null, "ts": 1765522457238, "time": "2025-12-12 06:54:17", "traceId": "cdefg"}
console.log(`api-call-error: status=${res.statusCode}`, responseData);
}
});
});
req.on('error', (error) => {
console.log('run-error:', error.message);
});
req.end();
} catch (error) {
console.log('run-error:', error.message);
}
}
main();