SoumyaJ commited on
Commit
1c92419
·
verified ·
1 Parent(s): 8e06e17

Update workflow_invocation.py

Browse files
Files changed (1) hide show
  1. 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
- json_response = response.json()
26
- print(json_response)
27
- return json_response
 
 
 
 
 
 
28
  #print("Response status code:", response.json())
 
 
 
 
29
  except Exception as e:
30
- print(f"An error occurred: {e}")
 
 
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