For this thing I besought the Lord thrice, that it might depart from me. 2 Corinthians 12:8

It may seem from this text that Paul had not by any means prayed in faith, for we read everywhere in Scripture, that we shall obtain whatever we ask in faith. Paul prays, and does not obtain." I answer, that as there are different ways of asking, so there are different ways of obtaining. We ask in simple terms those things as to which we have an express promise -- as, for example, the perfecting of God's kingdom, and the hallowing of his name, (Matthew 6:9,) the remission of our sins, and every thing that is advantageous to us; but, when we think that the kingdom of God can, nay must be advanced, in this particular manner or in that, and what is necessary for the hallowing of his name, we are often mistaken in our opinion. In like manner, we often fall into a serious mistake as to what tends to promote our own welfare.We ask for things confidently, and without any reservation, while we do not have the right to prescribe the means for receiving them. If, however, we specify the means, there is always a condition implied, though not expressed. Now Paul was not so ignorant as not to know this. Hence, as to the object of his prayer, there can be no doubt that he was heard, although he met with a refusal as to the express form. By this we are admonished not to give way to despondency as if our prayers had been lost labor when God does not gratify or comply with our wishes, but that we must be satisfied with his grace, that is, in respect of our not being forsaken by him. For the reason, why he sometimes mercifully refuses to his own people, what, in his wrath, he grants to the wicked, is this -- that he foresees better what is expedient for us, than our understanding is able to apprehend.
~ John Calvin.