Skip to content

Commit 1732f7a

Browse files
authored
fix: serialize datetime fields when creating queue items (#670) (#1607)
1 parent fa66211 commit 1732f7a

6 files changed

Lines changed: 47 additions & 9 deletions

File tree

packages/uipath-platform/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-platform"
3-
version = "0.1.40"
3+
version = "0.1.41"
44
description = "HTTP client library for programmatic access to UiPath Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

packages/uipath-platform/src/uipath/platform/orchestrator/_queues_service.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@ def _create_item_spec(
454454
elif isinstance(item, QueueItem):
455455
queue_item = item
456456

457-
item_data = queue_item.model_dump(exclude_unset=True, by_alias=True)
457+
item_data = queue_item.model_dump(
458+
mode="json", exclude_unset=True, by_alias=True
459+
)
458460
resolved_name = queue_name or item_data.get("Name")
459461
if resolved_name is None:
460462
raise ValueError(
@@ -493,9 +495,11 @@ def _create_items_spec(
493495
"queueName": queue_name,
494496
"commitType": commit_type.value,
495497
"queueItems": [
496-
item.model_dump(exclude_unset=True, by_alias=True)
498+
item.model_dump(mode="json", exclude_unset=True, by_alias=True)
497499
if isinstance(item, QueueItem)
498-
else QueueItem(**item).model_dump(exclude_unset=True, by_alias=True)
500+
else QueueItem(**item).model_dump(
501+
mode="json", exclude_unset=True, by_alias=True
502+
)
499503
for item in items
500504
],
501505
},
@@ -519,7 +523,7 @@ def _create_transaction_item_spec(
519523
transaction_item = item
520524

521525
transaction_data = transaction_item.model_dump(
522-
exclude_unset=True, by_alias=True
526+
mode="json", exclude_unset=True, by_alias=True
523527
)
524528
resolved_name = queue_name or transaction_data.get("Name")
525529
if resolved_name is None:
@@ -580,7 +584,7 @@ def _complete_transaction_item_spec(
580584
),
581585
json={
582586
"transactionResult": transaction_result.model_dump(
583-
exclude_unset=True, by_alias=True
587+
mode="json", exclude_unset=True, by_alias=True
584588
)
585589
},
586590
headers={

packages/uipath-platform/tests/services/test_queues_service.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from datetime import datetime, timezone
23

34
import pytest
45
from pytest_httpx import HTTPXMock
@@ -518,6 +519,39 @@ async def test_create_item_with_reference_async(
518519
== f"UiPath.Python.Sdk/UiPath.Python.Sdk.Activities.QueuesService.create_item_async/{version}"
519520
)
520521

522+
def test_create_item_with_datetime_fields(
523+
self,
524+
httpx_mock: HTTPXMock,
525+
service: QueuesService,
526+
base_url: str,
527+
org: str,
528+
tenant: str,
529+
) -> None:
530+
defer = datetime(2026, 5, 1, 9, 0, 0, tzinfo=timezone.utc)
531+
due = datetime(2026, 5, 2, 17, 30, 0, tzinfo=timezone.utc)
532+
risk = datetime(2026, 5, 2, 12, 0, 0, tzinfo=timezone.utc)
533+
queue_item = QueueItem(
534+
priority=QueueItemPriority.NORMAL,
535+
specific_content={"key": "value"},
536+
defer_date=defer,
537+
due_date=due,
538+
risk_sla_date=risk,
539+
)
540+
httpx_mock.add_response(
541+
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Queues/UiPathODataSvc.AddQueueItem",
542+
status_code=200,
543+
json={"Id": 1},
544+
)
545+
546+
service.create_item(queue_item, queue_name="test-queue")
547+
548+
sent_request = httpx_mock.get_request()
549+
assert sent_request is not None
550+
body = json.loads(sent_request.content.decode())
551+
assert body["itemData"]["DeferDate"] == defer.isoformat()
552+
assert body["itemData"]["DueDate"] == due.isoformat()
553+
assert body["itemData"]["RiskSlaDate"] == risk.isoformat()
554+
521555
def test_create_transaction_item(
522556
self,
523557
httpx_mock: HTTPXMock,

packages/uipath-platform/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/uipath/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ requires-python = ">=3.11"
77
dependencies = [
88
"uipath-core>=0.5.8, <0.6.0",
99
"uipath-runtime>=0.10.1, <0.11.0",
10-
"uipath-platform>=0.1.39, <0.2.0",
10+
"uipath-platform>=0.1.41, <0.2.0",
1111
"click>=8.3.1",
1212
"httpx>=0.28.1",
1313
"pyjwt>=2.10.1",

packages/uipath/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)