[Python] Mstrio-py can't establish connection due to Invalid URL

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    CODE:

    import json
    from mstrio.connection import Connection

    base_url = "https://myURL/MSTAWS/MicroStrategyAPI/api/"
    mstr_username = "myusername"
    mstr_password = "mypassword"
    project_name = "myproject"
    conn = Connection(base_url, mstr_username, mstr_password, project_name=project_name)



    Error code : raise InvalidURL(f"Invalid URL {url!r}: No host supplied")


    requests.exceptions.InvalidURL: Invalid URL 'https:/api/auth/login': No host supplied


    From my research it looks like the base URL is not getting passed to the prepare_URL function

    code block from "requests" library "models.py" file

    def prepare_url(self, url, params):
    """Prepares the given HTTP URL."""
    #: Accept objects that have string representations.
    #: We're unable to blindly call unicode/str functions
    #: as this will include the bytestring indicator (b'')
    #: on python 3.x.
    #: https://github.com/psf/requests/pull/2238
    if isinstance(url, bytes):
    url = url.decode("utf8")
    else:
    url = str(url)

    # Remove leading whitespaces from url
    url = url.lstrip()

    # Don't do any URL preparation for non-HTTP schemes like `mailto`,
    # `data` etc to work around exceptions from `url_parse`, which
    # handles RFC 3986 only.
    if ":" in url and not url.lower().startswith("http"):
    self.url = url
    return

    # Support for unicode domain names and paths.
    try:
    scheme, auth, host, port, path, query, fragment = parse_url(url)
    except LocationParseError as e:
    raise InvalidURL(*e.args)

    if not scheme:
    raise MissingSchema(
    f"Invalid URL {url!r}: No scheme supplied. "
    f"Perhaps you meant https://{url}?"
    )

    if not host:
    raise InvalidURL(f"Invalid URL {url!r}: No host supplied")


    would someone be able to help me find out why the url is not getting passed when i set it as a parameter withen the connection class?

    I tried re-adding mstrio-py dependencies to see if that would fix it.

    Continue reading...

Compartilhe esta Página