Fix notice errors and logging of error logic

Fixed a notice error and the logic of logging the errors if the curl request failed