I went to one of my friend's flat. One of the boy over there called me and said he'll beat me up if I won't allow him to have sex with me. I was afraid. And didn't know what to do. I had sex with him. Later then I knew it was Haram! Is there anyway to ask forgiveness? Any dua?
Allah accepts only the repentance of those who do evil in ignorance and foolishness and repent soon afterwards; it is they to whom Allah will forgive and Allah is Ever All-Knower, All-Wise. (Qur'an 4:17)
Well the verse pretty well answers your query, because Allah is all knower, well aware of what you do, if you truly repent in front of Allah, he will surely accept your repentance. And make sure you don't repeat it from next time, and take every necessary measure possible & let not fate (your stupid environment) force you to do that again.
Way to ask forgiveness
Make sure you stick to your Salah (Namaz) constantly and simply repent from the bottom of your heart.
May the creator guide us all.