No exception is thrown and the count of the sites is correct.
import asyncio
import os
from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient
credentials = ClientSecretCredential(
"TENANT_ID",
"CLIENT_ID",
"CLIENT_SECRET",
)
client = GraphServiceClient(credentials=credentials)
async def get_sites_with_url():
# workaround
# client.path_parameters["baseurl"] = client.request_adapter.base_url
print(f"Path parameters: {client.path_parameters}")
url = client.sites.to_get_request_information().url
print(f"Url: {url}")
sites = await client.sites.with_url(url).get()
print(f"#sites: {len(sites.value)}")
def main():
asyncio.run(get_sites_with_url())
if __name__ == "__main__":
main()
Path parameters: {'base_url': 'https://graph.microsoft.com/v1.0'}
Url: /sites
Traceback (most recent call last):
File "/Users/luis.anselmo/projects/test.py", line 39, in <module>
main()
File "/Users/luis.anselmo/projects/test.py", line 35, in main
asyncio.run(get_sites_with_url())
File "/Users/luis.anselmo/.pyenv/versions/3.11.2/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/luis.anselmo/.pyenv/versions/3.11.2/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/luis.anselmo/.pyenv/versions/3.11.2/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/luis.anselmo/projects/test.py", line 30, in get_sites_with_url
sites = await client.sites.with_url(url).get()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/luis.anselmo/.pyenv/versions/3.11.2/lib/python3.11/site-packages/msgraph/generated/sites/sites_request_builder.py", line 71, in get
return await self.request_adapter.send_async(request_info, SiteCollectionResponse, error_mapping)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/luis.anselmo/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kiota_http/httpx_request_adapter.py", line 182, in send_async
response = await self.get_http_response_message(request_info, parent_span)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/luis.anselmo/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kiota_http/httpx_request_adapter.py", line 532, in get_http_response_message
await self._authentication_provider.authenticate_request(
File "/Users/luis.anselmo/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kiota_abstractions/authentication/base_bearer_token_authentication_provider.py", line 50, in authenticate_request
token = await self.access_token_provider.get_authorization_token(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/luis.anselmo/.pyenv/versions/3.11.2/lib/python3.11/site-packages/kiota_authentication_azure/azure_identity_access_token_provider.py", line 77, in get_authorization_token
raise exc
kiota_authentication_azure._exceptions.HTTPError: Valid url scheme and host required
Describe the bug
I am trying to get
sitesusingwith_urlas first call, but an exception is thrown.Expected behavior
No exception is thrown and the count of the sites is correct.
How to reproduce
SDK Version
1.14.0
Latest version known to work for scenario above?
No response
Known Workarounds
Add
baseurlto theclient.path_parametersafter creating the client.like so:
client.path_parameters["baseurl"] = client.request_adapter.base_urlDebug output
Configuration
Other information
No response