In an aprotic solvent, 3-cyanopyridine and a solid halogenating reagent are added, and the mixture is heated to 50-150℃ for 6-30 hours. An extractant, water, and a reducing agent are added, and the mixture is stirred for 10-30 minutes. The pH is adjusted to alkaline with an alkaline solution, and the organic phase is concentrated. The organic phase is dissolved in a polar solvent, and water is added dropwise to precipitate a solid. The solid is collected by filtration. Concentrated hydrochloric acid is added to the solid, and the mixture is heated to 95-100℃ for 30-60 minutes. The pH is adjusted to 1-4 with an alkaline solution, precipitating a white solid to obtain 5-halogenated nicotinic acid. The synthesis of 2,5-dichloronicotinic acid can be attempted by changing the halogenating reagent used in the synthesis.