Fixed incorrect handeling of errors in http request. Added error handeler and correct timing of binding for binding variable