Python Code Error by Indeeds Support

ichilddev

Member
Your Workflow URL
https://connect.pabbly.com/workflow/share/AEhRY1IFBWYHTQNpUjcFIgEVBQFXDlMwUksFF1RbVy8DTVMoAUBYMlwQVnQDQFMyAksEblUJDTcLHwYCVwFSIVVYACxSUVAqVRgGfQFMCjkAXlF5UjM#
Your Task History ID
IjU3NjUwNTY0MDYzMzA0MzA1MjY5NTUzYzUxMzA1MTZiNTQzNzBmMzMi_pc
Consent to Access & Modify
I authorize Pabbly Support to log in to my account and make changes to the specified workflow for troubleshooting.
Dear Sir/Mdm,

Refer to thread: https://forum.pabbly.com/threads/we...t-into-array-intact-for-itemizer.34420/page-2

Your kind support has actually assist to create the python code back then that assist to extract figures from webhook (JSON)

Today we have met this error out of sudden.

Workflow: HC Create Monthly Report
Task ID: IjU3NjUwNTY0MDYzMzA0MzA1MjY5NTUzYzUxMzA1MTZiNTQzNzBmMzMi_pc

The resultant file output: https://docs.google.com/spreadsheets/d/1Bx1Q-ng1TDTvzUuZnEtkSfeQLltI6Yvf_VwhbxmQGD4/edit?usp=sharing (There is no rows of data which ought to be retrieved by Step 3: Extract Report Data.


Error: See attached.
WE don't have this error before. Kindly advise as soon?
 

Attachments

  • Error.png
    Error.png
    131.8 KB · Views: 18

ArshilAhmad

Well-known member
Staff member
We’ve made a slight change to the code again. Please test it now.
Python:
import json

raw_data = """{ ... your full JSON exactly as-is ... }"""

report_month = "Mar 2026"

# 1) Slice JSON safely
start = raw_data.find("{")
end = raw_data.rfind("}") + 1
cleaned = raw_data[start:end]

# 2) FIX: escape newline characters for JSON
cleaned = cleaned.replace("\n", "\\n")

# 3) Parse JSON
try:
    data = json.loads(cleaned, strict=False)
except Exception as e:
    raise Exception("JSON parsing failed: " + str(e))

# 4) Get students
students = data.get("Students", [])
if not students:
    raise Exception("No students found in data")

# 5) Build result
result = {key: [] for key in students[0].keys()}

for student in students:
    for key in result:
        result[key].append(str(student.get(key, "")))

# 6) Add MonthReport
result["MonthReport"] = ", ".join([report_month] * len(students))

# 7) Convert lists to strings
for key in result:
    if isinstance(result[key], list):
        result[key] = ", ".join(result[key])

print(json.dumps(result, indent=2))

Thanks & Regards,
Arshil Ahmad
Customer Support Associate
🌐 Pabbly.com
👉Rate your support
 
Top