Message malformed: extra keys not allowed @ data['action']

Dear Community,

i´m trying to get a script working that is downloading a jpg from a cam
and save it to a folder:

service: downloader.download_file
data:
url: ‘http://192.168.0.23:81/snapshot.cgi?user=&pwd=
subdir: ‘cams’
filename: cam_eingang.jpg
overwrite: true

When i run this in the “Developer Tools - Services Tab” it is working without a Problem.

Then i wanted to put it into a script or automation:

alias: Cam Eingang Snapshot
action:
service: downloader.download_file
data:
url: ‘http://192.168.0.23:81/snapshot.cgi?user=&pwd=
subdir: ‘cams’
filename: cam_eingang.jpg
overwrite: true

But as soon as i want to save the script or automation i´ll get the error message:
Message malformed: extra keys not allowed @ data[‘action’]

What extra keys???

Any help is appreciated.

It seems like you have no indentation/formatting at all there, and that’s going to be a problem. I recommend reviewing how YAML formatting works.

You’ll probably need something like this:

service: downloader.download_file
data:
  url: 'http://192.168.0.23:81/snapshot.cgi?user=&pwd='
  subdir: 'cams'
  filename: cam_eingang.jpg
  overwrite: true

It probably works in the dev tools because the “service data” box has an implied data:, and you don’t need to indent the contents that go in the box itself.

Your quotes were also “smart quotes”, and I changed them to normal single quotes. Make sure to check that in the future as well.

Extra keys are invalid options you have supplied. In other words, you have entered something that doesn’t belong there.

If you use action in a script, it is invalid and will be reported as:

Message malformed: extra keys not allowed @ data[‘action’]

action is only valid in an automation.