James 1:5 If any of you lack wisdom, let him ask of God, that giveth to all men liberally, and upbraids not; and it shall be given him. 6 But let him ask in faith, nothing wavering. For he that wavers is like a wave of the sea driven with the wind and tossed.
There is an attitude out there where some persons feel that if they pray long and hard enough, they will succeed in shaking down a blessing from God, even if He does not agree. This stop and frisk attitude is not in harmony with our first passages, and must be avoided like the plague. The purpose of us making prayer requests to God is not to change His mind, but rather to bring us into harmony with His good and perfect will.
And, the opening passages do speak of a turning away from known sin, in order to receive and answer. This is of critical importance to receiving any answers from God. When king Saul dug in his heels in deliberate sinning God could not hear his requests, for he came to the throne of grace laden with presumptuous sins, and therefore, he could not get an answer from God, not even a no. Things have to be pretty bad for a person not to get even a No from The Lord.
There are certain prayer requests that would always get a yes answer, such as when one sincerely asks for forgiveness during their probationary time. But the requests for divine intervention, or deliverance, or a specific request such as God providing this or that in the temporal realm, those should follow the guidance given in the scriptures. Thus, we must study the preconditions in the Bible thoroughly, so that our prayers would not hit the ceiling, instead of reaching into the heavens where God is seated on His throne.
James 1:7 For let not that man think that he shall receive any thing of the Lord. 8 A double minded man is unstable in all his ways.
May The Lord add His blessing to the study of His word. God bless!