microsoftgraph / microsoftgraph/msgraph-sdk-python

Object has no attribute 'get_all' when calling calendar.get_schedule.post()

Open
#451 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
630
Forks
96
Avg merge
15h 20m
Merged PRs (30d)
3

Description

I'm currently trying to get a room schedule through this code:

credential = ClientSecretCredential(
    config['tenantID'],
    config['clientID'],
    config['clientSecret']
)
scopes = ['https://graph.microsoft.com/.default']
client = GraphServiceClient(credentials=credential, scopes=scopes)

# GET /users/{id | userPrincipalName}
async def get_rooms():
    
    request_body = GetSchedulePostRequestBody(
        schedules = [
            "StanzaA@qq7h.onmicrosoft.com"
        ],
        start_time = DateTimeTimeZone(
            date_time = "2023-03-15T09:00:00",
            time_zone = "Pacific Standard Time",
        ),
        end_time = DateTimeTimeZone(
            date_time = "2023-12-15T18:00:00",
            time_zone = "Pacific Standard Time",
        ),
        availability_view_interval = 60,
    )

    request_configuration = GetScheduleRequestBuilder.GetScheduleRequestBuilderPostRequestConfiguration(
    headers = {
            'Prefer' : "outlook.timezone=\"Pacific Standard Time\"",
    }

    )

    result = await client.me.calendar.get_schedule.post(request_body, request_configuration = request_configuration)


    if result:
        print(result.value)

asyncio.run(get_rooms())

But when running I get an error coming from kiota

Traceback (most recent call last):
  File "C:\Users\Massimo Mendozza\Documents\GitHub\DynamicsToJoan\main.py", line 52, in <module>
    asyncio.run(get_rooms())
  File "C:\Users\Massimo Mendozza\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Massimo Mendozza\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Massimo Mendozza\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Massimo Mendozza\Documents\GitHub\DynamicsToJoan\main.py", line 46, in get_rooms
    result = await client.me.calendar.get_schedule.post(request_body, request_configuration = request_configuration)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Massimo Mendozza\Documents\GitHub\DynamicsToJoan\Lib\site-packages\msgraph\generated\users\item\calendar\get_schedule\get_schedule_request_builder.py", line 40, in post
    request_info = self.to_post_request_information(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Massimo Mendozza\Documents\GitHub\DynamicsToJoan\Lib\site-packages\msgraph\generated\users\item\calendar\get_schedule\get_schedule_request_builder.py", line 66, in to_post_request_information        
    request_info.headers.add_all(request_configuration.headers)
  File "C:\Users\Massimo Mendozza\Documents\GitHub\DynamicsToJoan\Lib\site-packages\kiota_abstractions\headers_collection.py", line 83, in add_all
    for key, values in headers.get_all().items():
                       ^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'get_all'

I'm currently running under this pyvenv:

home = C:\Users\Massimo Mendozza\AppData\Local\Programs\Python\Python311
include-system-site-packages = false
version = 3.11.0
executable = C:\Users\Massimo Mendozza\AppData\Local\Programs\Python\Python311\python.exe
command = C:\Users\Massimo Mendozza\AppData\Local\Programs\Python\Python311\python.exe -m venv C:\Users\Massimo Mendozza\Documents\GitHub\DynamicsToJoan

And this are my packages version:

Package                              Version
------------------------------------ ---------
aiohttp                              3.8.6
aiosignal                            1.3.1
anyio                                4.0.0
async-timeout                        4.0.3
attrs                                23.1.0
azure-core                           1.29.5
azure-identity                       1.15.0
certifi                              2023.7.22
cffi                                 1.16.0
charset-normalizer                   3.3.2
cryptography                         41.0.5
Deprecated                           1.2.14
frozenlist                           1.4.0
h11                                  0.14.0
h2                                   4.1.0
hpack                                4.0.0
httpcore                             0.18.0
httpx                                0.25.0
hyperframe                           6.0.1
idna                                 3.4
importlib-metadata                   6.8.0
microsoft-kiota-abstractions         1.0.0
microsoft-kiota-authentication-azure 1.0.0
microsoft-kiota-http                 1.0.0
microsoft-kiota-serialization-json   1.0.0
microsoft-kiota-serialization-text   1.0.0
msal                                 1.24.1
msal-extensions                      1.0.0
msgraph-core                         1.0.0a4
msgraph-sdk                          1.0.0
multidict                            6.0.4
opentelemetry-api                    1.20.0
opentelemetry-sdk                    1.20.0
opentelemetry-semantic-conventions   0.41b0
pendulum                             2.1.2
pip                                  22.3
portalocker                          2.8.2
pycparser                            2.21
PyJWT                                2.8.0
python-dateutil                      2.8.2
python-dotenv                        1.0.0
pytzdata                             2020.1
pywin32                              306
requests                             2.31.0
setuptools                           65.5.0
six                                  1.16.0
sniffio                              1.3.0
std-uritemplate                      0.0.46
typing_extensions                    4.8.0
urllib3                              2.0.7
wrapt                                1.15.0
yarl                                 1.9.2
zipp                                 3.17.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the request configuration and headers handling in the traceback's generated get_schedule_request_builder.py, then read kiota_abstractions/headers_collection.py where get_all() is called. Check what header type the request configuration expects and compare it with the dict used in the example. Done means the reported request no longer fails at headers.add_all and the expected header behavior is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.