remove redundant code for POST methods in REST API

use functional programming 'map' to reduce the code