microsoftgraph / microsoftgraph/msgraph-sdk-python

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

Đang mở
#451 5 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug
Ngôn ngữ chính
Python
Star
630
Fork
96
Merge trung bình
15 giờ 20 phút
Pull request đã merge (30 ngày)
3

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với cấu hình request và việc xử lý headers trong get_schedule_request_builder.py được tạo ra trong traceback, sau đó đọc kiota_abstractions/headers_collection.py, nơi get_all() được gọi. Kiểm tra loại header mà cấu hình request mong đợi và so sánh với dict được sử dụng trong ví dụ. Được xem là hoàn tất khi request được báo cáo không còn lỗi tại headers.add_all và hành vi header mong đợi đã được xác minh.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.