logging errors from api requests. swapping time and endtime if needed.