Spaces:
Sleeping
Sleeping
Update workflow_invocation.py
Browse files- workflow_invocation.py +17 -5
workflow_invocation.py
CHANGED
@@ -18,14 +18,26 @@ class WorkflowInvocation:
|
|
18 |
async def invoke_workflow(self):
|
19 |
try:
|
20 |
webHookUrl = self.config['workflow']['webhook_url']
|
21 |
-
print(webHookUrl)
|
22 |
async with httpx.AsyncClient() as client:
|
23 |
response = await client.post(webHookUrl, json=self.payload)
|
24 |
response.raise_for_status()
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
#print("Response status code:", response.json())
|
|
|
|
|
|
|
|
|
29 |
except Exception as e:
|
30 |
-
|
|
|
|
|
31 |
|
|
|
18 |
async def invoke_workflow(self):
|
19 |
try:
|
20 |
webHookUrl = self.config['workflow']['webhook_url']
|
21 |
+
#print(webHookUrl)
|
22 |
async with httpx.AsyncClient() as client:
|
23 |
response = await client.post(webHookUrl, json=self.payload)
|
24 |
response.raise_for_status()
|
25 |
+
try:
|
26 |
+
# Try to parse JSON response
|
27 |
+
json_response = response.json()
|
28 |
+
print("JSON Response:", json_response)
|
29 |
+
return json_response
|
30 |
+
except Exception as e:
|
31 |
+
# Fall back to raw text
|
32 |
+
print("Non-JSON response:", response.text)
|
33 |
+
return response.text
|
34 |
#print("Response status code:", response.json())
|
35 |
+
except httpx.RequestError as e:
|
36 |
+
print(f"Request error occurred: {e}")
|
37 |
+
except httpx.HTTPStatusError as e:
|
38 |
+
print(f"HTTP error occurred: {e.response.status_code} - {e.response.text}")
|
39 |
except Exception as e:
|
40 |
+
import traceback
|
41 |
+
print("Unexpected error:", str(e))
|
42 |
+
traceback.print_exc()
|
43 |
|