Workflow automatically runs into error after few API calls
Hi Team
I am calling a Rebrandly API service to convert adobe generated WebApps link to short URLs. But after few calls (approx 1000 calls)/sometime (approx 12-15 mins) the workflow automatically runs into error as :-
"IOB-090008 Failure while resolving address 'api.rebrandly.com' (errno=-11)"
Find the code below used
var startLine = 0;
var limit = 9999;
var loop= true;
while (loop)
{
//Fetching the customerIDs dynamically
var query = xtk.queryDef.create(
<queryDef schema="temp:query" operation="select" startLine={startLine} limit={limit} >
<select>
<node expr="@SMS"/>
</select>
</queryDef>);
var res = query.ExecuteQuery();
if (Object.keys(res).length>0)
{
for each (var rcp in res.query)
{
//Fetching the customerIDs dynamically whose shortURL is EMPTY
var query2 = xtk.queryDef.create(
<queryDef schema="dbSchema" operation="select">
<select>
<node expr="@SMS"/>
<node expr="@shortURL"/>
</select>
<where>
<condition expr={"@SMS ='"+ rcp.@SMS+"'"}/>
</where>
</queryDef>);
var res2 = query2.ExecuteQuery();
for each (var rcp2 in res2.dbSchema)
{
//Condition to check if shortURL is EMPTY
if (rcp2.@shortURL == '')
{
var ID = rcp2.@SMS;
//Script to get the hashed ID.
var encrypt= cryptString(ID);
var url= escapeUrl(encrypt);
//Script to get the Full URL.
var fullURL = 'ADOBEGENERATEDURL'+url;
var Data = "{\"domain\":{\"id\":\"XYZ\"},\"destination\":\""+ fullURL+"\"}";
//API Call to get short URL.
var http=new HttpClientRequest("https://rebrandly.com/");
http.header ["Content-Type"] = "application/json";
http.header ["apikey"] = "ABC";
http.header ["workspace"] = "DEF";
http.header ["Accept"] = "application/json";
http.method = "POST" ;
http.body = Data;
http.execute();
var resposne = http.response.body;
//Get the response in string format.
var result = http.response.body.toString();
//Parse the response in JSON format.
var result3 = JSON.parse(resposne);
//Pull ShortURL in string format from parsed response.
var result6 = result3.shortUrl ;
}
}
}
startLine = startLine + limit +1;
}
else
loop=false;
}
Further, I have also tried to used "Keep Alive" mode to send requests but unfortunately it throws the below error :
"13/12/2022 13:08:32 js3 HTTP header 'WWW-Authenticate' used for proxy authentication not found."
Code used
//API connection
var http=new HttpClientRequest("https://rebrandly.com");
http.header ["Content-Type"] = "application/json";
http.header ["apikey"] = "ABC";
http.header ["workspace"] = "DEF";
http.header ["Accept"] = "application/json";
http.method = "POST" ;
http.connect();
// Connection kept alive
logInfo("Connection Established.");
var startLine = 0;
var limit = 9999;
var loop= true;
while (loop)
{
//Fetching the customerIDs dynamically
var query = xtk.queryDef.create(
<queryDef schema="temp:query" operation="select" startLine={startLine} limit={limit} >
<select>
<node expr="@SMS"/>
</select>
</queryDef>);
var res = query.ExecuteQuery();
if (Object.keys(res).length>0)
{
for each (var rcp in res.query)
{
//Fetching the customerIDs dynamically whose shortURL is EMPTY
var query2 = xtk.queryDef.create(
<queryDef schema="dbSchema" operation="select">
<select>
<node expr="@SMS"/>
<node expr="@shortURL"/>
</select>
<where>
<condition expr={"@SMS ='"+ rcp.@SMS+"'"}/>
</where>
</queryDef>);
var res2 = query2.ExecuteQuery();
for each (var rcp2 in res2.dbSchema)
{
//Condition to check if shortURL is EMPTY
if (rcp2.@shortURL == '')
{
var ID = rcp2.@SMS;
//Script to get the hashed ID.
var encrypt= cryptString(ID);
var url= escapeUrl(encrypt);
//Script to get the Full URL.
var fullURL = 'ADOBEGENERATEDURL'+url;
var Data = "{\"domain\":{\"id\":\"XYZ\"},\"destination\":\""+ fullURL+"\"}";
//API Call to get short URL.
http.body = Data;
http.execute();
var resposne = http.response.body;
//Get the response in string format.
var result = http.response.body.toString();
//Parse the response in JSON format.
var result3 = JSON.parse(resposne);
//Pull ShortURL in string format from parsed response.
var result6 = result3.shortUrl ;
}
}
}
startLine = startLine + limit +1;
}
else
loop=false;
}
Could you please give any suggestions or workaround for the same?
Regards
Akshay
