Fix the undefined index 'id' in case of error

In every case of error, the code use request['id']. But, the id is optional and aren't checked before. This will trigger the  warning "undefined index". Fix it.