How do I find a replacement rear axle? My back wheel stopped free wheeling so we took out the back wheel and opened the hub to find that the axle is bent. So we threw away the axle and thought to replace wheel. Now I know the axle can be replaced but i don't know the dimensions of the axle i had.

i looked at the specifications for my bike but i couldn't find any detailing on the rear axle length and diameter. my bike is: https://www.giant-bicycles.com/au/xtc-27dot5-2-2014

How can I find a replacement for my rear axle?
Your bike appears to have "Giant Tracker Sport Disc" hubs. They appear to use cartridge bearings. Additionally, some service manual PDFs found online make it appear axle removal is a somewhat involved process, and so your axle removal may have disturbed some bearings. It also appears to use a proprietary axle type but I'm not 100% on that.

Take your bike to where you bought it or another giant dealer, as they'll have the specialized tooling needed to fix your bearings and will be able to order a new axle.