i made a config that is kinda long and on the last block i make a get request but sometimes i get a respond code that contains false that i stat as retry but i cant al the times that i get retry start fro begining again how could i fix this issue ?
Here is an example on how to do this:
(retries the request if the response code is not 200)
#retry_the_request
BLOCK:HttpRequest
LABEL:request that fails
method = GET
TYPE:STANDARD
$""
"application/x-www-form-urlencoded"
ENDBLOCK
if (CheckCondition(data, data.RESPONSECODE.AsInt(), NumComparison.NotEqualTo, 200))
{
goto retry_the_request;
return;
}
Or if u want it to retry if data.SOURCE contains “false”:
#retry_the_request
BLOCK:HttpRequest
LABEL:request that fails
method = GET
TYPE:STANDARD
$""
"application/x-www-form-urlencoded"
ENDBLOCK
if (CheckCondition(data, data.SOURCE.AsString(), StrComparison.Contains, "false"))
{
goto retry_the_request;
return;
}
thank you for the help again, how can i add like it ll try again if response false but like just a few time not till it get something else then false
Here is an example that tries it up to 3 times before marking the account as CUSTOM:
int retryCount = 0;
const int maxRetries = 3;
#retry_the_request
BLOCK:HttpRequest
LABEL:request that fails
method = GET
TYPE:STANDARD
$""
"application/x-www-form-urlencoded"
ENDBLOCK
if (CheckCondition(data, data.SOURCE.AsString(), StrComparison.Contains, "false"))
{
retryCount++;
if (retryCount >= maxRetries)
{
data.STATUS = "CUSTOM";
}
else
{
goto retry_the_request;
}
}
thank you do u have any video to learn more about c#
what if i need to use a loop to search for an email ll it works aswell ?
what do u mean exactly
i mean instead of searching for a response on the data.source i should search inside the block imapReadMailOutput like this
imapReadMailOutput DoseNotContain true it loop like if it waiting for that email u know what i mean ?
like this?
int retryCount = 0;
const int maxRetries = 3;
#retry_the_request
BLOCK:HttpRequest
LABEL:request that fails
TYPE:STANDARD
$""
"application/x-www-form-urlencoded"
ENDBLOCK
if (CheckCondition(data, imapReadMailOutput.AsString(), StrComparison.DoesNotContain, "true"))
{
retryCount++;
if (retryCount >= maxRetries)
{
data.STATUS = "CUSTOM";
}
else
{
goto retry_the_request;
}
}
if you are waiting for a email i suggest also adding a delay block before the request block.
also if you want to change the condition u can make a keycheck block, and put in the condition (for example if imapReadMailOutput does not contain true) then switch to c#
and then u can copy the CheckCondition line and use it in the lolicode:
ok and if the email should contain a var instead of a bool should i use it like this
int retryCount = 0;
const int maxRetries = 3;
#retry_the_request
BLOCK:HttpRequest
LABEL:request that fails
TYPE:STANDARD
$""
"application/x-www-form-urlencoded"
ENDBLOCK
if (CheckCondition(data, imapReadMailOutput.AsString(), StrComparison.DoesNotContain, $"<var>"))
{
retryCount++;
if (retryCount >= maxRetries)
{
data.STATUS = "CUSTOM";
}
else
{
goto retry_the_request;
}
}
Then it would be like this:
int retryCount = 0;
const int maxRetries = 3;
#retry_the_request
BLOCK:HttpRequest
LABEL:request that fails
TYPE:STANDARD
$""
"application/x-www-form-urlencoded"
ENDBLOCK
if (CheckCondition(data, imapReadMailOutput.AsString(), StrComparison.DoesNotContain, myvariable.AsString()))
{
retryCount++;
if (retryCount >= maxRetries)
{
data.STATUS = "CUSTOM";
}
else
{
goto retry_the_request;
}
}
where “myvariable” should be the variable name
ok and if i want to parse and check if inside the parse block theres a variable i tried with the last loli u send but kinda dosent work
then u replace “imapReadMailOutput” with the name of the parse block output (for example: parseOutput)
i try it but it dosent find the variable in the prase
BLOCK:ImapSearchMails
field1 = From
SAFE
=> CAP @imapSearchMailsOutput
ENDBLOCK
BLOCK:Delay
milliseconds = 10
ENDBLOCK
int retryCount = 0;
const int maxRetries = 3;
#retry_the_request
BLOCK:ImapReadMail
id = $"<imapSearchMailsOutput[0]>"
SAFE
=> VAR @imapReadMailOutput
ENDBLOCK
BLOCK:Parse
input = @data.SOURCE
MODE:LR
=> VAR @parseOutput
ENDBLOCK
if (CheckCondition(data, parseOutput.AsString(), StrComparison.DoesNotContain, parseOutput.AsString()))
{
retryCount++;
if (retryCount >= maxRetries)
{
data.STATUS = "CUSTOM";
}
else
{
goto retry_the_request;
}
}
u know what i mean ?
Why are u parsing data.SOURCE and checking against that? Shouldn’t it be imapReadMailOutput?
yea i trie both and dont works either
check the message I sent u.