Error "AppendRecord column schema mismatch" when using scrape task to insert data

I’m trying to use a task, which is scraping a Prometheus URL, similar to this: Experimental prometheus.scrape() function | Flux 0.x Documentation

It is working, when I’m just using the built-in scraper, but this scraps every 10s (too fast for me).

But it doesn’t work as a script/task, with the following error:

 runtime error @6:5-6:66: to: AppendRecord column schema mismatch

InfluxDB is 2.0.7

(If I ommit the “to” the graph is shown as expected)

My script is the same as of the example, but with only my values (url, org, bucket).

import "experimental/prometheus"

prometheus.scrape(url: "https://example-url.com/metrics")
  |> to(
    org: "example-org",
    bucket: "example-bucket"
  )