Page 1 of 1

Fetch to variable in function does not work

Posted: Fri Oct 12, 2018 6:00 pm
by man
I'm going to be mad ...

Spend hours on this function and can't make it working.
When i have added and then called it from ssh terminal works like a charm!
But when i have added it via script, i just get an on error block ("status"="failed") as a result.
:global FUNfetchToAsArr do={ 
	:do {   
	:log warning message="url=$url"; 
	:log warning message="http-data=$data";
	:local res [/tool fetch mode=$POSTMODE url=$url http-method=post http-data="$data" as-value output=user check-certificate=yes-without-crl];
	:log warning message="RESULT = $res";
		:return $res;
	} on-error={
		:return ({"status"="failed"});
May someone help and describe why, when i have edded this function via terminal, it works well (i receive the result of port request), but when it is added from script, i get only :return ({"status"="failed"});

Futher in script this function is called like that:
:local result [$FUNfetchToAsArr url=$URL data=$postData];

Re: Fetch to variable in function does not work

Posted: Sun Oct 14, 2018 8:08 am
by man
Ok. Guess, it is dummy issue, when I have forgotten to declare global variable before it's usage