Muwatta Malik, Book 14, Hadith 2 (USC-MSA)

Yahya related to me from Malik from one of the Ansar that the Messenger of Allah, may Allah bless him and grant him peace, forbade defecating or urinating while facing the qibla.

وَحَدَّثَنِي عَنْ مَالِكٍ، عَنْ نَافِعٍ، عَنْ رَجُلٍ، مِنَ الأَنْصَارِ أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم نَهَى أَنْ تُسْتَقْبَلَ الْقِبْلَةُ لِغَائِطٍ أَوْ بَوْلٍ ‏.‏

sunnah.com

also referenced under: Book 14, Hadith 459 (In-Book)