Selective ammonolysis of carboxylic acid derivatives