Matthew 7:7-8: "7 'Ask, and it will be given to you; seek, and you will find; knock, and it will be opened to you. 8 For everyone who asks receives, and the one who seeks finds, and to the one who knocks it will be opened.'"
Hebrews 4:15: "For we do not have a high priest who is unable to sympathize with our weaknesses, but one who in every respect has been tempted as we are, yet without sin."
John 15:14-16: "14 'You are my friends if you do what I command you. 15 No longer do I call you servants, for the servant does not know what his master is doing; but I have called you friends, for all that I have heard from my Father I have made known to you. 16 You did not choose me, but I chose you and appointed you that you should go and bear fruit and that your fruit should abide, so that whatever you ask the Father in my name, he may give it to you.'"
1 Peter 2:24: "He himself bore our sins in his body on the tree, that we might die to sin and live to righteousness. By his wounds you have been healed."
+++
The text is public domain:
1 What a friend we have in Jesus,All our sins and griefs to bear!What a privilege to carryEv'rything to God in prayer!Oh, what peace we often forfeit;Oh, what needless pain we bear -All because we do not carryEv'rything to God in prayer!2 Have we trials and temptations?Is there trouble anywhere?We should never be discouraged -Take it to the Lord in prayer.Can we find a friend so faithfulWho will all our sorrows share?Jesus knows our ev'ry weakness -Take it to the Lord in prayer.3 Are we weak and heavy laden,Cumbered with a load of care?Precious Savior, still our refuge -Take it to the Lord in prayer.Do thy friends despise, forsake thee?Take it to the Lord in prayer.In His arms He'll take and shield thee;Thou wilt find a solace there.
+++
The passage from Matthew 7 and the end of John 15:16 seem to appear in the recurring references to prayer ("What a privilege to carry / Ev'rything to God in prayer" in the first verse and "Take it to the Lord in prayer" in the second and third).
Hebrews 4:15 appears in the lines "Can we find a friend so faithful / Who will all our sorrows share? / Jesus knows our ev'ry weakness" in the second verse.
The passage from John 15 is the basis for the line "What a friend we have in Jesus," although there's a bit of overlap with Hebrews 4:15, and 1 Peter 2:24 appears in the following line: "All our sins and griefs to bear!"
+++
The repeated reference to prayer may allude to "Be constant in prayer" from Romans 12:12. The first half of the second verse also bears some similarity to Philippians 4:6: "do not be anxious about anything, but in everything by prayer and supplication with thanksgiving let your requests be made known to God."