The story, described in the Bhavishya Parva of the Harivamsa, is related to the aftermath of Janamejaya’s sarpa satra and him having finished listening to Vaishampayana’s narration of Mahabharata and Shri Krishna’s Leela. Janamejaya performed the horse sacrifice where Indra possessed the horse and having intercourse with the queen (actually Apsara Rambha), made Janamejaya deviate from performing the sacrifice.
The story is as follows:
After the passage of some time, king janamejaya, who offers plenty of tributes (in sacrifices) observed the horse sacrifice as ordained. Devi Vapushtama, the daughter of the king of kashi, went and slept with the slain horse, according to the ritual as prescribed. Seeing the queen with beautiful limbs, Vasava (indra) desired her. Entering the body of the dead horse, indra had intercourse with the queen. When the passion was born and realizing the truth, the king told the officiating priest responsible for ritually killing the animal (adhvaryu): The horse killed (ritually) by you is not dead. The officiating knowledgable priest told the king sage (janamejaya): This is the action of Indra. Then the king cursed Indra.
King Janamejaya is livid with Indra, the officiating priests and his wife:
Janamejaya said, “From today, no Kshatriya will worship indra of the deva-s, who has not conquered his senses and who is not having a fixed mind, with the horse sacrifice.” Becoming angry, king janamejaya also told the officiating priests, “This sacrifice is wrecked because of your weakness. Hence you will not live on my land. You shall go away (from my land) along with your relatives.” The officiating priests who were told thus abandoned the king due to anger. Because of anger, the most righteous king janamejaya, ordered the women who were in his wife's residence, about his wife. Expel the unfaithful Vapushtama from my residence. She has put her (dirty) leg, smeared with dust on my head. (She has insulted me).
-Harivamsa Bhavishya Parva chapter 5 verses 11-21
However, at this time a Gandharva king Vishvavasu comes and explains that the Queen is actually Apsara Rambha and Indra merely created an illusion of intercourse with her to provoke Janamejaya’s anger. Also that the Queen was not tainted with such an act:
the Gandharva says, “Vasava (indra) does not tolerate you who has observed three hundred penances. Hence he made a divine woman as your wife Vapushtama. The daughter of the king of Kashi (Vapushtama) is the divine woman, Rambha. O king! She is the best among woman, a jewel. You can accept her. Knowing about the (horse) sacrifice, indra created obstacles for your sacrifice. The one who observed the sacrifice, you, are the best among the kurus, equal to vAsava in prosperity. O king! Due to the results of the sacrifice (which you are going to get on its completion), shakra (indra) is afraid of you O lord! That is why shakra wrecked your sacrifice. This is an illusion shown by vAsava (indra), desiring to prevent your sacrifice. Knowing about the sacrifice, indra possessed the (dead ) horse and had sex with rambhA, whom you consider as vapuShTamA. shakra (indra), by force, made you and the brahmins deviate (from doing the sacrifice). These priests who officiated for you for performing three hundred sacrifices were made undesirable by you. vAsava (indra) was always afraid of you and the best of brahmaNa-s. shakra (indra) conquered both (fears) with one act of illusion. Will the destroyer of cities (puraMdara, indra) of high splendor, desirous of victory, ever take the wife of the great grandson (janamejaya), which is never done by others?
-Harivamsa Bhavishya Parva chapter 5 verses 25-33
Vishva Vasu then convinces Janamejaya of his wife’s innocence and Janamejaya gladly accepts her:
Discarding your fever of anger accept this jewel of women (your wife vapuShTamA) who has not committed any sin. If the women who are not sinners are discarded, then the other women will discard you. O king! (janamejaya! vishvAsasu continued) The women, especially the divine women, do not have any defect. Even the light of the sun, the flame of fire, the sacrificial stage as well as the oblations to the sacred fire try to spoil them , the women will not be spoiled.
-Harivamsa Bhavishya Parva chapter 5 verses 37-39