11import os
22import uuid
3- from json import dumps
43from typing import Any , Dict , List , Optional , Tuple
54
65from .._config import Config
@@ -81,30 +80,28 @@ def _create_spec(
8180 return RequestSpec (
8281 method = "POST" ,
8382 endpoint = Endpoint ("/orchestrator_/tasks/AppTasks/CreateAppTask" ),
84- content = dumps (
85- {
86- "appId" : app_key ,
87- "appVersion" : app_version ,
88- "title" : title ,
89- "data" : data if data is not None else {},
90- "actionableMessageMetaData" : {
91- "fieldSet" : {
92- "id" : str (uuid .uuid4 ()),
93- "fields" : field_list ,
94- }
95- if len (field_list ) != 0
96- else {},
97- "actionSet" : {
98- "id" : str (uuid .uuid4 ()),
99- "actions" : outcome_list ,
100- }
101- if len (outcome_list ) != 0
102- else {},
83+ json = {
84+ "appId" : app_key ,
85+ "appVersion" : app_version ,
86+ "title" : title ,
87+ "data" : data if data is not None else {},
88+ "actionableMessageMetaData" : {
89+ "fieldSet" : {
90+ "id" : str (uuid .uuid4 ()),
91+ "fields" : field_list ,
92+ }
93+ if len (field_list ) != 0
94+ else {},
95+ "actionSet" : {
96+ "id" : str (uuid .uuid4 ()),
97+ "actions" : outcome_list ,
10398 }
104- if action_schema is not None
99+ if len ( outcome_list ) != 0
105100 else {},
106101 }
107- ),
102+ if action_schema is not None
103+ else {},
104+ },
108105 headers = folder_headers (app_folder_key , app_folder_path ),
109106 )
110107
@@ -126,9 +123,7 @@ def _assign_task_spec(task_key: str, assignee: str) -> RequestSpec:
126123 endpoint = Endpoint (
127124 "/orchestrator_/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks"
128125 ),
129- content = dumps (
130- {"taskAssignments" : [{"taskId" : task_key , "UserNameOrEmail" : assignee }]}
131- ),
126+ json = {"taskAssignments" : [{"taskId" : task_key , "UserNameOrEmail" : assignee }]},
132127 )
133128
134129
@@ -224,12 +219,18 @@ async def create_async(
224219 )
225220
226221 response = await self .request_async (
227- spec .method , spec .endpoint , content = spec .content , headers = spec .headers
222+ spec .method ,
223+ spec .endpoint ,
224+ json = spec .json ,
225+ content = spec .content ,
226+ headers = spec .headers ,
228227 )
229228 json_response = response .json ()
230229 if assignee :
231230 spec = _assign_task_spec (json_response ["id" ], assignee )
232- await self .request_async (spec .method , spec .endpoint , content = spec .content )
231+ await self .request_async (
232+ spec .method , spec .endpoint , json = spec .json , content = spec .content
233+ )
233234 return Action .model_validate (json_response )
234235
235236 @traced (name = "actions_create" , run_type = "uipath" )
@@ -284,12 +285,18 @@ def create(
284285 )
285286
286287 response = self .request (
287- spec .method , spec .endpoint , content = spec .content , headers = spec .headers
288+ spec .method ,
289+ spec .endpoint ,
290+ json = spec .json ,
291+ content = spec .content ,
292+ headers = spec .headers ,
288293 )
289294 json_response = response .json ()
290295 if assignee :
291296 spec = _assign_task_spec (json_response ["id" ], assignee )
292- self .request (spec .method , spec .endpoint , content = spec .content )
297+ self .request (
298+ spec .method , spec .endpoint , json = spec .json , content = spec .content
299+ )
293300 return Action .model_validate (json_response )
294301
295302 @traced (name = "actions_retrieve" , run_type = "uipath" )
0 commit comments