Failing to get last login time for users via APIs

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 = api_instance.get_users(page_size=page_size, page_number=current_page, sort_order=sort_order, 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?

Hi,

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

Thanks,

Mike

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

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

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