Legacy Dev Forum Posts

 View Only

Sign Up

Failing to get last login time for users via APIs

  • 1.  Failing to get last login time for users via APIs

    Posted 06-05-2025 18:08

    Somik_Mukherjee1 | 2022-08-05 16:30:39 UTC | #1

    When calling the get_users API using Python SDK, we are finding this error:

    Exception when calling UsersApi->get_users: (0) Reason: Failed to parse 0000-12-30T00:00:00Z into a datetime object

    getUsers = apiinstance.getusers(pagesize=pagesize, pagenumber=currentpage, sortorder=sortorder, expand=list(["dateLastLogin"]), state=state)

    The min year within a date in python is 1 and since 0000 is less than the min date we are getting this error. How can we handle this to get the values?


    anon14299330 | 2022-08-08 15:08:23 UTC | #2

    Hi,

    Is this exception thrown when calling the API or when you are tying to parse the datetime object?

    Thanks,

    Mike


    Somik_Mukherjee1 | 2022-08-08 15:19:59 UTC | #3

    @anon14299330 : This is happening when calling the API along with the additional attribute "dateLastLogin" as expand values.


    anon14299330 | 2022-08-08 15:26:01 UTC | #4

    Hi,

    I believe the issue is with Pythons datetime.date class when parsing the datetime objects. The date class expects a year, month and day. According to the documentation, year must be between MINYEAR and MAXYEAR

    datetime.MINYEAR
    The smallest year number allowed in a date or datetime object. MINYEAR is 1.
    
    datetime.MAXYEAR
    The largest year number allowed in a date or datetime object. MAXYEAR is 9999.

    so python is throwing an exception when the date class is given a date with no year 0000. I will raise this issue with my team.

    Thanks,

    Mike


    system | 2022-09-08 15:26:38 UTC | #5

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 15806