In this paper , we use the outer-galactic HI scale height data as well as the observed rotation curve as constraints to determine the halo density distribution of the Andromeda galaxy ( M31 ) . We model the galaxy as a gravitationally-coupled system of stars and gas , responding to the external force-field of a known Hernquist bulge and the dark matter halo , the density profile of the latter being characterized by four free parameters . The parameter space of the halo is optimized so as to match the observed HI thickness distribution as well as the rotation curve on an equal footing , unlike the previous studies of M31 which were based on rotation curves alone . We show that an oblate halo , with an isothermal density profile , provides the best fit to the observed data . This gives a central density of 0.011 M _ { \odot } pc ^ { -3 } , a core radius of 21 kpc , and an axis ratio of 0.4 . The main result from this work is the flattened dark matter halo for M31 , which is required to match the outer galactic HI scale height data . Interestingly , such flattened halos lie at the most oblate end of the distribution of halo shapes found in recent cosmological simulations .