Amir bin Rabia reported,

We were with the Messenger of Allah ﷺ on a journey when the sky became overcast and the direction of the qiblah became unclear to us. So we prayed and marked the direction we faced. When the sun rose, we realized that we had prayed toward something other than the qiblah. We mentioned this to the Prophet ﷺ, and Allah revealed, "So wherever you turn, there is the Face of Allah" [Baqarah 2:115].

Ibn Majah 1020

Daif

حدثنا يحيى بن حكيم حدثنا أبو داود حدثنا أشعث بن سعيد أبو الربيع السمان عن عاصم بن عبيد الله

عن عبد الله بن عامر بن ربيعة عن أبيه قال

كنا مع رسول الله ﷺ في سفر فتغيمت السماء وأشكلت علينا القبلة فصلينا وأعلمنا فلما طلعت الشمس إذا نحن قد صلينا لغير القبلة فذكرنا ذلك للنبي ﷺ فأنزل الله {فأينما تولوا فثم وجه الله}

ابن ماجه 1020ضعيف
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
One who prays facing other than the qibla unknowingly
Numbering
Darussalam 1020
Ibn Majah 1020