1 Kings 17
1 Elijah the Tishbite, from Tishbe in Gilead, said to Ahab: “As the Lord, the God of Israel, lives, whom I serve, during these years there shall be no dew or rain except at my word.”
The phrase "As the Lord lives" is very different from "Thus says the Lord." The latter begins a prophecy. The former begins a definitive statement by the speaker, not God. Elijah says, in effect, "A surely as there is a God in Heaven, as certain as day follows night, there will be no rain!"
James apparently thought - or may have been aware of a rabbinical teaching - that Elijah's prophecystatement was a negative wish, a type of prayer. This is echoed by Rashi in his commentary on this verse:
'As Adonoy [the Lord] lives.' - Why was this phrase placed here?... Achov said to Eliyahu, “Is it possible that the student’s curse [should be] fulfilled while Moshe our teacher’s curse was not fulfilled?
Rashi preserves an ancient tradition in which Ahab challenged Elijah's authority by calling his prediction a curse by a mere apprentice. Moses' curses were not always fulfilled, he reasoned; and Elijah is surely not as great as Moses.
Conclusion: James refers to Elijah's 'prayer' because although Elijah invoked God's name, his statement was not actually a prophecy. It was a confident declaration that God would support his ardent negative wish or prayer. Because Elijah's wish was in accord with God's will, his prediction did come true.