def _create_rest_url(host, version, sid, category, resource, subcategory=
    None, query_id=None, second_query_id=None, **options):
    """Creates the URL for querying the REST service"""
    url = '/'.join([host, 'webservices/rest', version, category])
    if query_id is not None:
        url += '/' + query_id
    url += '/' + resource
    if second_query_id is not None:
        url += '/' + second_query_id
    if subcategory is not None:
        url += '/' + subcategory
    header = {'Accept-Encoding': 'gzip'}
    if sid is not None:
        header['Authorization'] = 'Bearer {}'.format(sid)
    if options is not None:
        opts = []
        for k, v in options.items():
            opts.append(k + '=' + str(v))
        if opts:
            url += '?' + '&'.join(opts)
    return url, header
