result returns just new line \n not whats printed after command is run
You could try replacing &gt; tomytextfile.txt with &gt; tomytextfile.txt 2&gt;&amp;1.

Similarly, you could use what is shown below. 

echo "result=`/usr/bin/dscl . -change /Users/admin NFSHomeDirectory /Users/admin /var/admin 2&gt;&amp;1`" | curl --data-urlencode result@- http://172.16.26.251:8080/script


Basically, 2&gt;&amp;1 redirects error output to regular output.