Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 15586

Scripting • Re: fetch - how receive response code

$
0
0
This seems to only work when the fetch result is successful.

If we try another example with a wrong URL (correct = reqbin.com), the result is only the error, not the failed status.
Code:
{  :local result [/tool fetch url=https://reqb.com/echo/get/json output=user as-value]  :if ($result->"status" = "failed") do={    :put ($result->"status")    # Empty status  } }
So, inside a script, it would be nice to treat the error with a friendlier message.
When a fetch fails, how can I capture the status and error message?

Statistics: Posted by diasdm — Sun Mar 24, 2024 4:11 am



Viewing all articles
Browse latest Browse all 15586

Trending Articles