Preparation of derivatives of carbamic acid