url_options are used to generate output of url_for  method. When called from api controller, the `url_options[:conroller] = '/api/hosts'` and `url_options[:_path_segments][:controller] = 'api/hosts'` which leads the url for unattended to be '/foreman/api/unattended` which break the unattended functionality.