JSON to Binary has stopped working!

Describe the issue/error/question

This is really weird. I’m progressively chasing through issues with a complex workflow I’m building. The last step of the process is supposed to generate me a nicely formatted powershell script from a number of previously set fields. This was working yesterday, not today. I have updated the N8N version since then but I don’t understand why it’s not working.

The node stopped producing output completely (returning blank binary data). I’ve fiddled with it and it’s now returning a copy of the input - which is of course JSON. I just want the value of the ‘data’ field, and the formatting (ie. line endings) to be honoured.

What is the error message (if any)?

Please share the workflow

Share the output returned by the last node

Returned output -

{"data":"<# This script takes care of creating a new user within xx's environment. It should be run on a Domain Controller in an Administrative Powershell. Please review the support ticket AND the details of the script (where noted) before continuing. This will create the user account and provide access to global wifi systems, along with an SSO account and associated pieces. All other on-site access must be provisioned manually #>\n\n$OU = Get-ADOrganizationalUnit -Filter 'Name -eq \"United Kingdom\"' -SearchBase \"OU=xx,OU=xx,DC=xx,DC=xxx\"\n$RegionOU = Get-ADOrganizationalUnit -Filter 'Name -eq \"Europe\"' -SearchBase \"OU=Users,OU=aa,DC=ss,DC=sdf\"\n\nif ($OU.DistinguishedName -eq $null) {\n\tif ($RegionOU.DistinguishedName -ne $null) {\n\t\tWrite-Host \"OU NOT FOUND. Going to create a new OU called 'United Kingdom'\"\n\t\tNew-ADOrganizationalUnit -Name \"United Kingdom\" -Path $RegionOU -Confirm\n\t\t$OU = Get-ADOrganizationalUnit -Filter 'Name -eq \"United Kingdom\"' -SearchBase \"OU=Users,OU=123,DC=sff,DC=we\"\n\t}\n}\n\nNew-ADUser -samAccountName \"Steve Smith\" -Identity \"Steve Smith\" -DisplayName \"Steve Smith\" -AccountPassword (ConvertTo-SecureString enkvisCSY5SA -AsPlainText -force) -Enabled $True -GivenName Steve -Surname Smith -UserPrincipalName [email protected] -EmailAddress [email protected] -Manager (Peter Williams) -Office \"Yepey Corporate\" -Department \"Finance Services\" -Title \"Accountant\" -HomePage www.yepey.co -Path $OU -Company \"Yepey Europe\" -Confirm\n\n$user = Get-ADUser -Filter \"userprincipalname -eq '[email protected]'\" -SearchBase \"OU=Users,OU=xx,DC=yy,DC=zz\"\n$group = \"CN=xxs,OU=Groups,OU=LocalResources,DC=xx,DC=xx\"\n\nwhile ($user -eq $null) {\n    Write-Host \"User account not yet present in directory. Waiting 5 seconds...\"\n    Start-Sleep 5\n}\n\nAdd-ADGroupMember -Identity $group -Members $user"}

Expected output -

<# This script takes care of creating a new user within xx's environment. It should be run on a Domain Controller in an Administrative Powershell. Please review the support ticket AND the details of the script (where noted) before continuing. This will create the user account and provide access to global wifi systems, along with an SSO account and associated pieces. All other on-site access must be provisioned manually #>

$OU = Get-ADOrganizationalUnit -Filter 'Name -eq "United Kingdom"' -SearchBase "OU=xx,OU=xx,DC=xx,DC=xxx"
$RegionOU = Get-ADOrganizationalUnit -Filter 'Name -eq "Europe"' -SearchBase "OU=Users,OU=aa,DC=ss,DC=sdf"

if ($OU.DistinguishedName -eq $null) {
	if ($RegionOU.DistinguishedName -ne $null) {
		Write-Host "OU NOT FOUND. Going to create a new OU called 'United Kingdom'"
		New-ADOrganizationalUnit -Name "United Kingdom" -Path $RegionOU -Confirm
		$OU = Get-ADOrganizationalUnit -Filter 'Name -eq "United Kingdom"' -SearchBase "OU=Users,OU=123,DC=sff,DC=we"
	}
}

New-ADUser -samAccountName "Steve Smith" -Identity "Steve Smith" -DisplayName "Steve Smith" -AccountPassword (ConvertTo-SecureString enkvisCSY5SA -AsPlainText -force) -Enabled $True -GivenName Steve -Surname Smith -UserPrincipalName [email protected] -EmailAddress [email protected] -Manager (Peter Williams) -Office "Yepey Corporate" -Department "Finance Services" -Title "Accountant" -HomePage www.yepey.co -Path $OU -Company "Yepey Europe" -Confirm

$user = Get-ADUser -Filter "userprincipalname -eq '[email protected]'" -SearchBase "OU=Users,OU=xx,DC=yy,DC=zz"
$group = "CN=xxs,OU=Groups,OU=LocalResources,DC=xx,DC=xx"

while ($user -eq $null) {
    Write-Host "User account not yet present in directory. Waiting 5 seconds..."
    Start-Sleep 5
}

Add-ADGroupMember -Identity $group -Members $user

Information on your n8n setup

  • n8n version: 0.205.0
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hi @Tom_Anderson, I am sorry to hear you’re having trouble.

I am afraid I am not able to reproduce the problem based on the example flow you have provided. It seems it depends on specific data returned by the Merge node and also on data coming from your When Called By Another Workflow node.

However, from looking at your Move Binary Data node I think you might simply need to

  1. Deactivate the “Convert All Data” option on the node (since you only want to use the data field)
  2. Enable the “Use Raw data” option to prevent the JSON.stringify() method from being applied

Like so:

This example would produce a file like this:

image

Thanks for the feedback.

I found the issue!

If I have ‘Source Key’ set as ‘data’, then it works fine. If I actually change this to the JS expression ({{ $json[“data”] }}) then it just writes an empty file.

Thanks for pointing me in the right direction!

1 Like

Sweet, glad to hear you figured it out and thanks so much for confirming!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.