1. Methyl 1H-indazole-5-carboxylate (2.5 g, 14 mmol) was dissolved in anhydrous DMF (45 mL) under nitrogen protection.
2. Potassium carbonate (K2CO3, 4.90 g, 35.5 mmol) and iodomethane (1.77 mL, 28.4 mmol) were added sequentially to the above solution.
3. The reaction mixture was stirred at room temperature for 2 hours, then warmed to 50 °C and continued stirring overnight.
4. Upon completion of the reaction, most of the DMF was removed by concentration under reduced pressure.
5. The concentrate was dissolved in ethyl acetate (EtOAc) and washed with saturated aqueous sodium chloride (NaCl).
6. The organic phase was separated, dried over anhydrous sodium sulfate (Na2SO4), filtered and concentrated to give the crude product.
7. The crude product was purified using a CombiFlash Fast Chromatography System (80g silica gel column, eluent 25-45% ethyl acetate/heptane) to afford methyl 1-methyl-1H-indazole-5-carboxylate (1.07g, 40% yield) and methyl 2-methyl-2H-indazole-5-carboxylate (227mg, 8.4% yield), respectively.