Fixed eventapi get method

id var was set in the if scope and doesn't exist outside, we need to set
the id outside the if to be able for the query.