add error handling for post api