It was narrated that Jabir bin 'Abdullah said: "The Messenger of Allah (ﷺ) said: 'Beware of stopping to rest and praying in the middle of the road, for it is the refuge of snakes and carnivorous animals, and beware of relieving yourselves in the middle of the road, for this is an act that provokes curses.'"
Source: sunnah.com
Other translations
Arabic
حَدَّثَنَا مُحَمَّدُ بْنُ يَحْيَى، حَدَّثَنَا عَمْرُو بْنُ أَبِي سَلَمَةَ، عَنْ زُهَيْرٍ، قَالَ قَالَ سَالِمٌ سَمِعْتُ الْحَسَنَ، يَقُولُ حَدَّثَنَا جَابِرُ بْنُ عَبْدِ اللَّهِ، قَالَ قَالَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ " إِيَّاكُمْ وَالتَّعْرِيسَ عَلَى جَوَادِّ الطَّرِيقِ وَالصَّلاَةَ عَلَيْهَا فَإِنَّهَا مَأْوَى الْحَيَّاتِ وَالسِّبَاعِ وَقَضَاءَ الْحَاجَةِ عَلَيْهَا فَإِنَّهَا مِنَ الْمَلاَعِنِ " .
sunnah.com