fixed error handling in POST.