API Gateway fixed and query almost complete

messy/functional build of export xml almost complete