Bare spaces aren’t legal in URIs. Whereas as a full web server may silently fix that error, it is quite likely that the Asterisk implementation is much more pedantic.
I suggest you to use a programming language like PHP where you can pass variable to the AMI action. and also make logical descicion like if() { } else {}
if you prefer to use the above method you cant use variables, you will need to define direct parameters , example :
action=command&command=sip%20show%20peer%20%20100 where 100 is the peer