I noticed that the current user name which i retrieve from SharePoint using REST API maybe different from the Resource name in Project Online. To solve this I needed to Get current user Enterprise Resource ID
After some research i found out that this can be achieved using JSOM.
Project Online provides an object called Enterprise Resource. Basically you can get the resource information from this object.
To get the current Resource Details you need to call the method getSelf()
Below is the code:
var projContext = new PS.ProjectContext('<pwa site url>');
var userid = enterpriseresources.get_id();