Ajax call works for logged in users and returns “Bad Request” for guests [duplicate]

The action for non-logged in users is wp_ajax_nopriv_{$action}.