If you want to make primary and secondary amides instead of unsubstituted ones the best is to mix ester and the corresponding amine without solvent, alternatively an aprotic solvent with an high boiling point is a good choice (try to keep temperature above the boiling point of the alcohol that is produced and to remove it.