Can't register new Windows Puppet client

Registering a new Windows Puppet client fails with this error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Failed when searching for node Failed to find via exec: Execution of '/etc/puppetlabs/puppet/node.rb' returned 1:

I can register Linux hosts fine.

Expected outcome:
Node registers and gets a catalogue from the Puppet server.

Foreman and Proxy versions:

Foreman and Proxy plugin versions:

Distribution and version:

Other relevant data:
I have tried running node.rb from the Puppet server and get this output:

[root@server ~]# /etc/puppetlabs/puppet/node.rb During the fact upload the server responded with: 500 Internal Server Error. Error is ignored and the execution continues.
  "error": {"message":"resource have no errors"}
Error retrieving node Net::HTTPNotFound
Check Foreman's /var/log/foreman/production.log for more information.

A facts file has been successfully created for my new node in /opt/puppetlabs/server/data/puppetserver/yaml/facts/.

I have tried running “foreman-rake puppet:import:hosts_and_facts”, but that did not make any difference.

A number of similar issues have suggested checking /etc/puppetlabs/puppet/foreman.yaml - the settings here all seem fine.

I finally got this working. I had to enable the settings “Create new host when facts are uploaded” and “Create new host when report is uploaded” and now Puppet works fine.