I need your help in getting Watson Assistant Logs. I am getting an error “Rate limit exceeded”. According to API docs, we can specify cursor in param. When cursor is specified we can make 120 requests / min. If cursor is not specified then we can make 40 requests / 30min only. I have passed cursor attribute in “param” object as empty string when it first initiates and then I have updated the cursor value to next_cursor value which was returned by Watson (pagination attribute as a token). However, still its making 40 requests and connection gets closed for 30 min. Could you please tell me what I am doing wrong? I am able to retrieve 40 logs in text file. I am using Node JS. I am looking forward to hearing from you.
Below is the small sample function which I have created:
const getLogs = () => {
const params = {
workspace_id: '50f6598a-a369-45df-9cfb-20bdfe617066',
cursor: ""
}
service.listLogs(params)
.then(res => {
if(res.pagination.next_cursor) {
fs.writeFile("temp.txt", JSON.stringify(res, null, 2), err => {
if (err) console.log(err);
console.log("Successfully Written to File.");
});
params.cursor = res.pagination.next_cursor;
getLogs()
} else {
console.log('no more logs')
}
})
.catch(err => console.log(JSON.stringify(err, null, 2)));
}
getLogs();
{
"name": "Too Many Requests",
"code": 429,
"message": "Rate limit exceeded",
"body": "{\"error\":\"Rate limit exceeded\",\"code\":429}",
"headers": {
"x-backside-transport": "FAIL FAIL",
"content-type": "application/json; charset=utf-8",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS",
"access-control-allow-headers": "Content-Type, Content-Length, Authorization, X-Watson-Authorization-Token, X-WDC-PL-OPT-OUT, X-Watson-UserInfo, X-Watson-Learning-Opt-Out, X-Watson-Metadata",
"access-control-max-age": "3600",
"content-security-policy": "default-src 'none'",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN",
"strict-transport-security": "max-age=31536000;",
"x-download-options": "noopen",
"x-content-type-options": "nosniff",
"x-xss-protection": "1; mode=block",
"x-ratelimit-limit": "40",
"x-ratelimit-reset": "1559060571",
"x-ratelimit-remaining": "0",
"retry-after": "1143.36",
"x-global-transaction-id": "7ecac92c5ced5be3440b2991",
"x-dp-watson-tran-id": "gateway01-1141582225",
"x-dp-transit-id": "gateway01-1141582225",
"content-length": "42",
"x-edgeconnect-midmile-rtt": "256",
"x-edgeconnect-origin-mex-latency": "210",
"date": "Tue, 28 May 2019 16:03:47 GMT",
"connection": "close"
}
}