You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SharePoint Custom Fields (Single line of text) - Gets cast to Python Pendulam DateTime #653
Hi Everyone, doing a simple call to a SharePoint Document library to return the custom metadata fields related to a file. What's interesting is I can set the column type to 'Single line of text' in SharePoint but if I put certain numbers into the column it returns as a datetime object.
If I put text in the field on SharePoint it returns correctly as text or even if I put enough numbers it returns as text as well.
In the example below the Doc_ID column in SharePoint contains the numbers 1212.
result = await (
client.drives.by_drive_id(drive_id)
.items.by_drive_item_id(drive_item_id)
.list_item.get()
)
print(result.fields.additional_data["Doc_x0020_ID"])
print(type(result.fields.additional_data["Doc_x0020_ID"]))
I am seeing a similar issues when querying entraid attributes. Any value that has a 4-digit numerical value is being returned as a datetime object instead of a string. If I get the raw http response the value is returned as a string correctly. It would be great if this was looked into and resolved as I prefer not to have to get the native HTTPX response.
Hello, and thanks for continued use of the SDK and for raising this.
As we look into our serialization to give a consistent behaviour, would you cast the result to a string/datetime object for now:
Pendulum to string
# Cast Pendulum DateTime to stringpendulum_datetime_string=pendulum_datetime.to_iso8601_string()
print("Pendulum DateTime as string (ISO 8601 format):", pendulum_datetime_string)
string to pendulum
# Parse the string to Pendulum DateTime objectpendulum_datetime=pendulum.parse(pendulum_datetime_if_string)
Shem Ogumbe (@shemogumbe) I am not really sure how that is helpful? Are you suggesting I cast this to a string then truncate the string to get the 4 digit value. That sounds like a messy solution to be honest.
I have actually just implemented georgethomasii suggestion to just get the raw response and get the metadata more reliably there.
Activity
georgethomasii commentedon Apr 8, 2024
I am seeing a similar issues when querying entraid attributes. Any value that has a 4-digit numerical value is being returned as a datetime object instead of a string. If I get the raw http response the value is returned as a string correctly. It would be great if this was looked into and resolved as I prefer not to have to get the native HTTPX response.
shemogumbe commentedon Apr 23, 2024
Hello, and thanks for continued use of the SDK and for raising this.
As we look into our serialization to give a consistent behaviour, would you cast the result to a string/datetime object for now:
nikhilmakan02 commentedon Apr 23, 2024
Shem Ogumbe (@shemogumbe) I am not really sure how that is helpful? Are you suggesting I cast this to a string then truncate the string to get the 4 digit value. That sounds like a messy solution to be honest.
I have actually just implemented georgethomasii suggestion to just get the raw response and get the metadata more reliably there.
56badkarma commentedon Aug 19, 2026
Anyone still dealing with this issue:
microsoft/kiota-python/pull/664
merged and released last week. Latest version has the real fix.