Nigerian police spokesman Oduniyi Omotayo told AFP "The incident happened in Rafin Daji, a boundary community between Niger (state) and the FCT... 22 were confirmed kidnapped."
He said the abductions happened on Wednesday.
"The farmers were on their farmland working when gunmen outnumbered and kidnapped them," Omotayo said in a message.
Police and other security agencies "stormed the forest" in a bid to rescue the victims, he added.
Heavily-armed criminals known locally as bandits frequently attack rural areas with poor security in the northwest and central regions, but mass kidnappings are rare in the Federal Capital Territory (FCT).
Nigerian troops are fighting on several fronts, including in the northeast where jihadists have waged a 13-year-old insurgency and in the southeast where separatists operate.
But violence perpetrated by bandit militias is on the rise, with 50 percent more incidents in 2021 compared to the previous year, according to the Armed Conflict Location & Event Data Project (ACLED).
Nigeria's bandits killed more than 2,600 civilians in 2021, an increase of over 250 percent compared with 2020, according to the charity that collects data.
This figure far exceeds the official number of civilian fatalities resulting from the jihadist insurgency.
Most kidnappings are financially driven, with victims often released after a ransom payment, but there are concerns that some groups are linked to jihadist cells.