Skip to content

microsoft_graph_call_records_get_pstn_calls_with_from_date_time_with_to_date_time API failure #1234

Open
@thorfi

Description

@thorfi

Describe the bug

I'm trying to use the above api and when calling it with valid datetime objects, I get this - it seems something is wrong with the request formatting.

  File "/Users/username/PycharmProjects/redacted/redacted-root-fs/opt/redacted/bin/redacted-agent.py", line 225, in get_communications_call_records_pstn_calls
    pstn_calls_get = await graph_call_records.microsoft_graph_call_records_get_pstn_calls_with_from_date_time_with_to_date_time(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username/PycharmProjects/redacted/.venv/lib/python3.12/site-packages/msgraph/generated/communications/call_records/microsoft_graph_call_records_get_pstn_calls_with_from_date_time_with_to_date_time/microsoft_graph_call_records_get_pstn_calls_with_from_date_time_with_to_date_time_request_builder.py", line 57, in get
    return await self.request_adapter.send_async(request_info, GetPstnCallsWithFromDateTimeWithToDateTimeGetResponse, error_mapping)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username/PycharmProjects/redacted/.venv/lib/python3.12/site-packages/kiota_http/httpx_request_adapter.py", line 193, in send_async
    await self.throw_failed_responses(response, error_map, parent_span, parent_span)
  File "/Users/username/PycharmProjects/redacted/.venv/lib/python3.12/site-packages/kiota_http/httpx_request_adapter.py", line 575, in throw_failed_responses
    raise exc
msgraph.generated.models.o_data_errors.o_data_error.ODataError:
        APIError
        Code: 400
        message: None
        error: MainError(additional_data={}, code='BadRequest', details=None, inner_error=InnerError(additional_data={}, client_request_id='a2df585a-db1a-49f6-813f-a4590775a846', date=datetime.datetime(2025, 5, 28, 3, 32, 49), odata_type=None, request_id='bc5007c6-4ec4-4aac-ac01-1b7d4ea22acb'), message="The DateTimeOffset text '2025-05-28T03:22:47+00:00toDateTime=2025-05-28T03:32:47+00:00' should be in format 'yyyy-mm-ddThh:mm:ss('.'s+)?(zzzzzz)?' and each field value is within valid range.", target=None)

Expected behavior

Should get call logs

How to reproduce

#!/usr/bin/env python3

import asyncio
from datetime import datetime, timedelta

from azure.identity import DefaultAzureCredential
from msgraph import GraphServiceClient

# https://learn.microsoft.com/en-us/graph/api/callrecords-callrecord-getpstncalls?view=graph-rest-1.0&tabs=http
async def get_communications_call_records_pstn_calls(graph_service, from_date_time, to_date_time):
    graph_call_records = graph_service.communications.call_records
    pstn_calls_get = await graph_call_records.microsoft_graph_call_records_get_pstn_calls_with_from_date_time_with_to_date_time(
        from_date_time=from_date_time, to_date_time=to_date_time).get()

    pstn_call_rows = []
    while pstn_calls_get:
        pstn_call_rows.extend(pstn_calls_get.value)
        if pstn_calls_get.odata_next_link:
            pstn_calls_get = await graph_call_records.with_url(pstn_calls_get.odata_next_link).get()
        else:
            pstn_calls_get = None
    return pstn_call_rows

def main():
    azure_credential = DefaultAzureCredential()
    scopes = ['https://graph.microsoft.com/.default']
    # noinspection PyTypeChecker
    graph_service = GraphServiceClient(credentials=azure_credential, scopes=scopes)
    to_date_time = datetime.now()
    from_date_time = to_date_time - timedelta(minutes=10)
    asyncio.run(get_communications_call_records_pstn_calls(graph_service, from_date_time, to_date_time))

if __name__ == "__main__":
    main()

SDK Version

1.31.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

No response

Configuration

  • OS: macOS 15.5 (24F74)
  • architecture: ARM64

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:waiting-for-triageAn issue that is yet to be reviewed or assignedtype:bugA broken experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions