Fixed error in saving errors in api