I came across various questions but none of them could solve my problem. I wrote a simple doPost() code in google app script:
doPost()
function doPost(e)
One of the reason can be you are using a Rest client like Postman. It won't work, though I don't know the reason why.
Try with a normal form like this and it will work:
First name: Last name: