Hadithcore
Sahih Muslim, 2688 a
sahih

Anas reported that Allah's Messenger (ﷺ) visited a person from amongst the Muslims in order to inquire (about his health) who had grown feeble like the chicken. Allah's Messenger (ﷺ) said:

Did you supplicate for anything or beg of Him about that? He said: Yes. I used to utter (these words): Impose punishment upon me earlier in this world, what You are going to impose upon me in the Hereafter. Thereupon Allah's Messenger (ﷺ) said: Hallowed be Allah, you have neither the power nor forbearance to take upon yourself (the burden of His Punishment). Why did you not say this: O Allah, grant us good in the world and good in the Hereafter, and save us from the torment of Fire. He (the Prophet) made this supplication (for him) and he was all right.

حَدَّثَنَا أَبُو الْخَطَّابِ، زِيَادُ بْنُ يَحْيَى الْحَسَّانِيُّ حَدَّثَنَا مُحَمَّدُ بْنُ أَبِي عَدِيٍّ، عَنْ حُمَيْدٍ، عَنْ ثَابِتٍ، عَنْ أَنَسٍ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم عَادَ رَجُلاً مِنَ الْمُسْلِمِينَ قَدْ خَفَتَ فَصَارَ مِثْلَ الْفَرْخِ فَقَالَ لَهُ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ هَلْ كُنْتَ تَدْعُو بِشَىْءٍ أَوْ تَسْأَلُهُ إِيَّاهُ ‏"‏ ‏.‏ قَالَ نَعَمْ كُنْتُ أَقُولُ اللَّهُمَّ مَا كُنْتَ مُعَاقِبِي بِهِ فِي الآخِرَةِ فَعَجِّلْهُ لِي فِي الدُّنْيَا ‏.‏ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ سُبْحَانَ اللَّهِ لاَ تُطِيقُهُ - أَوْ لاَ تَسْتَطِيعُهُ - أَفَلاَ قُلْتَ اللَّهُمَّ آتِنَا فِي الدُّنْيَا حَسَنَةً وَفِي الآخِرَةِ حَسَنَةً وَقِنَا عَذَابَ النَّارِ ‏"‏ ‏.‏ قَالَ فَدَعَا اللَّهَ لَهُ فَشَفَاهُ ‏.‏

References2 variants
In-Book Reference
Book 48, Hadith 31
USC-MSA web (English) reference
Book 35, Hadith 6501 (deprecated numbering scheme)