Save JSON to File

I am attempting to save data from the Syncro node to a file. We have cancelled Syncro and want to take a full export of all our tickets. N8N is best suited for this because it includes data the built-in Syncro export does not (specifically, ticket comments). I had originally attempted to go from the Syncro node to a Move Binary Data node and then Write Binary Data, but that wants to create a file for each item that the Syncro node pulls (there are 3000+). I’m trying to avoid directly talking to their API using an HTTP request node because then I have to deal with pagination, whereas the Syncro node will grab everything at once. So I literally just want to take the JSON that the Syncro node outputs and dump it to a file so I can do something else with it later. Thank you.

Here is a modified sample of the JSON data produced by the node (2 items).

[
   {
      "id":54205337,
      "number":8834,
      "subject":"Update NAS",
      "created_at":"2022-04-25T07:02:03.535-06:00",
      "customer_id":23255041,
      "customer_business_then_name":"Joe Blow Professional Services",
      "due_date":"2022-04-28T07:02:03.529-06:00",
      "resolved_at":null,
      "start_at":null,
      "end_at":null,
      "location_id":null,
      "problem_type":"Software",
      "status":"New",
      "ticket_type_id":null,
      "properties":{
         "Feedback":"0",
         "Device Age":"",
         "Turnaround":"",
         "Image Password":"",
         "Please Describe the Issue":""
      },
      "user_id":24223,
      "updated_at":"2022-04-25T07:02:03.943-06:00",
      "pdf_url":null,
      "priority":"2 Normal",
      "comments":[
         {
            "id":192828783,
            "created_at":"2022-04-25T07:02:03.594-06:00",
            "updated_at":"2022-04-25T07:02:03.594-06:00",
            "ticket_id":54205337,
            "subject":"Initial Issue",
            "body":"Run software update on Joe Blow DSM and remount encrypted shares",
            "tech":"IT - John Smith",
            "hidden":false,
            "user_id":24223
         }
      ],
      "user":{
         "id":24223,
         "email":"[email protected]",
         "full_name":"IT - John Smith",
         "created_at":"2015-11-27T13:15:09.066-07:00",
         "updated_at":"2022-04-25T07:44:36.559-06:00",
         "group":"Admins",
         "admin?":true,
         "color":"DEBB27"
      }
   },
   {
      "id":54128496,
      "number":8833,
      "subject":"word document error msg",
      "created_at":"2022-04-21T16:48:08.781-06:00",
      "customer_id":6779660,
      "customer_business_then_name":"Michael Orthodontics",
      "due_date":"2022-04-24T16:48:08.771-06:00",
      "resolved_at":"2022-04-23T10:03:17.242-06:00",
      "start_at":null,
      "end_at":"2022-04-21T16:48:08.017-06:00",
      "location_id":0,
      "problem_type":"Other",
      "status":"Resolved",
      "ticket_type_id":null,
      "properties":{
         "Key":null,
         "Value":null
      },
      "user_id":null,
      "updated_at":"2022-04-23T10:03:17.243-06:00",
      "pdf_url":null,
      "priority":null,
      "comments":[
         {
            "id":192748819,
            "created_at":"2022-04-23T10:03:17.218-06:00",
            "updated_at":"2022-04-23T10:03:17.218-06:00",
            "ticket_id":54128496,
            "subject":"Update",
            "body":"Edits made via Bulk Update Tool - see change log for this timestamp",
            "tech":"[email protected]",
            "hidden":true,
            "user_id":null
         },
         {
            "id":192597367,
            "created_at":"2022-04-21T16:48:11.393-06:00",
            "updated_at":"2022-04-21T16:48:11.393-06:00",
            "ticket_id":54128496,
            "subject":"Info",
            "body":"ITSP Information Note Affected User: Assistant [email protected] Agent Name: MLO47",
            "tech":"IT - John Smith",
            "hidden":false,
            "user_id":24223
         },
         {
            "id":192597365,
            "created_at":"2022-04-21T16:48:10.959-06:00",
            "updated_at":"2022-04-21T16:48:10.959-06:00",
            "ticket_id":54128496,
            "subject":"Approval Data Note",
            "body":"ITSP Approval Note Status: Ticket APPROVED! Approval Users: Wendy <[email protected]> Action Performed By: Wendy <[email protected]>",
            "tech":"IT - John Smith",
            "hidden":true,
            "user_id":24223
         },
         {
            "id":192597364,
            "created_at":"2022-04-21T16:48:10.006-06:00",
            "updated_at":"2022-04-21T16:48:10.006-06:00",
            "ticket_id":54128496,
            "subject":"Diagnostic Data Note",
            "body":"############ System Information ############ Host Name: MLO47 OS Name: Microsoft Windows 10 Pro",
            "tech":"IT - John Smith",
            "hidden":true,
            "user_id":24223
         },
         {
            "id":192597363,
            "created_at":"2022-04-21T16:48:09.233-06:00",
            "updated_at":"2022-04-21T16:48:09.233-06:00",
            "ticket_id":54128496,
            "subject":"Initial Issue",
            "body":"this message pops up every time I open a word document Attachments word error msg.jpg ",
            "tech":"IT - John Smith",
            "hidden":false,
            "user_id":24223
         }
      ],
      "user":null
   }
]
1 Like

Hey @cleveradmin, thanks so much for sharing this example data set!

My suggestion would be to aggregate the data you have into a single item before doing anything else. You can then convert this item into binary data and write it to a file (or upload it to a cloud storage, FTP etc.).

Here’s an example workflow creating a single binary item from your example data:

I am using the Function node in this example as it runs only once, no matter how many input items there are and have it output a single item.

Hope this helps!