microsoftgraph / microsoftgraph/msgraph-sdk-python
Object has no attribute 'get_all' when calling calendar.get_schedule.post()
未关闭
还没有人认领这个 Issue。
bug
- 主要语言
- Python
- 星标
- 630
- 派生
- 96
- 平均合并
- 15 小时 20 分钟
- 30 天内合并 PR
- 3
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先检查 traceback 中生成的 get_schedule_request_builder.py 里的请求配置和 headers 处理,然后阅读调用 get_all() 的 kiota_abstractions/headers_collection.py。检查请求配置所期望的 header 类型,并将其与示例中使用的 dict 进行比较。当报告的请求不再在 headers.add_all 处失败,并且预期的 header 行为得到验证时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100