merge common PUT/POST functionality