kiota icon indicating copy to clipboard operation
kiota copied to clipboard

KeyError - unexpected argument deltatoken

Open shemogumbe opened this issue 9 months ago • 4 comments

Not sure this is the best place to raise this, doing so coz it affects all Languages.

The docs show than SDKs have deltatoken key that can be used to get the delta token the SDKs and the HTTP call both point to the same error:

HTTP Call doing a call to The api does not recognise - https://graph.microsoft.com/v1.0/applications/delta?deltatoken=latest Gives:

{
    "error": {
        "code": "Request_BadRequest",
        "message": "Unrecognized query argument specified: 'deltatoken'.",
        "innerError": {
            "date": "2024-04-28T16:30:39",
            "request-id": "f2ea5621-e131-47c3-9ee2-d1bd91f96236",
            "client-request-id": "f7d27604-49ba-7cfd-b151-19d46c093e3f"
        }
    }
}

If the API does not support the argument, why do we have it in our SDKs and snippets.

A call to the C# snippet here gives:

Unhandled exception. Microsoft.Graph.Models.ODataErrors.ODataError: Unrecognized query argument specified: 'deltatoken'.

A similar call to Python snippet returns:

Result: Failure Exception: TypeError: DeltaRequestBuilder.DeltaRequestBuilderGetQueryParameters.__init__() got an unexpected keyword argument 'deltatoken' Stack: File "/azure-functions-...

Possible workarounds Loop through the get requests, following @odata.NextLink to the last page, the use odata_delta_link, and extract deltatoken from it

async def get_user_delta(max_calls=10):
    try:

        # user dela
        url = "https://graph.microsoft.com/v1.0/applications/delta"
        calls = 0
        while calls < max_calls:
            response = await user_client.applications.delta.with_url(url).get()
            print(calls)
            if response.odata_next_link:
                url = response.odata_next_link
            elif response.odata_delta_link:
                print(response.odata_delta_link)
                return response.odata_delta_link
            calls += 1

    except APIError as e:
        print(f"Error: {e.response_status_code}: {e.message}")

This might not be efficient if the loops are too many, in my case it worked as we got the deltatoken on the third iteration of Optionally, use the page iterator

shemogumbe avatar Apr 29 '24 11:04 shemogumbe