Preparation of metal complexes containing carboxylic acid moieties