Magnetic flux ropes are the centerpiece of solar eruptions. Direct measurements for the magnetic field of flux ropes are crucial for understanding the triggering and energy release processes, yet they remain heretofore elusive. Here we report microwave imaging spectroscopy observations of an M1.4-class solar flare that occurred on 2017 September 6, using data obtained by the Expanded Owens Valley Solar Array. This flare event is associated with a failed eruption of a twisted filament observed in Hɑ by the Goode Solar Telescope at the Big Bear Solar Observatory. The filament, initially located along the magnetic polarity inversion line prior to the event, undergoes a failed eruption during the course of the flare. The upper portion of the erupting filament has a counterpart in microwaves, whose spectral properties indicate gyrosynchrotron radiation from flare-accelerated nonthermal electrons. Using spatially resolved microwave spectral analysis, we derive the magnetic field strength along the filament spine, which ranges from 600–1400 Gauss from its apex to the legs. The results agree well with the non-linear force-free magnetic model extrapolated from the pre-flare photospheric magnetogram. The multi-wavelength signatures of the event are consistent with the standard scenario of eruptive flares, except that the eruption failed to fully develop and escape as a coronal mass ejection. We conclude that the failed eruption is likely due to the strong strapping coronal magnetic field above the filament.